home *** CD-ROM | disk | FTP | other *** search
/ Kit PC World De Ampliacion De Windows 95 / Kit PC World de ampliacion de Windows 95.iso / clarion / cw15 / tpw15.z / CTLBROW.TPW < prev    next >
Text File  |  1995-09-06  |  93KB  |  2,271 lines

  1. #CONTROL(BrowseBox,'File-Browsing List Box'),PRIMARY('File-Browsing List Box',OPTKEY),DESCRIPTION('Browse on ' & %Primary),MULTI,WINDOW,HLP('~TPLControlBrowseBox')
  2.   CONTROLS
  3.     LIST,AT(,,150,100),USE(?List),IMM,FROM(Queue:Browse),MSG('Browsing Records')
  4.   END
  5. #LOCALDATA
  6. RecordFiltered       LONG
  7. #ENDLOCALDATA
  8. #BUTTON('&Browse Box Behavior'),AT(10,,180)
  9.   #SHEET
  10.     #TAB('&Default Behavior'),HLP('~TPLControlBrowseBox_Default_Behavior')
  11.       #PROMPT('&Quick-Scan Records (buffered reads)',CHECK),%EnableQuickScan,DEFAULT(0),AT(10,30,180)
  12.       #ENABLE(%PrimaryKey)
  13.         #PROMPT('&Locator:',DROP('None|Step|Entry|Incremental')),%LocatorType,DEFAULT('Step')
  14.         #BOXED('Entry/Incremental Locator'),WHERE(%LocatorType = 'Entry' OR %LocatorType = 'Incremental')
  15.           #PROMPT('&Override default locator control',CHECK),%OverrideDefaultLocator,AT(10,,180)
  16.           #ENABLE(%OverrideDefaultLocator)
  17.             #PROMPT('&New Locator Control:',CONTROL),%OverrideLocator,REQ
  18.           #ENDENABLE
  19.         #ENDBOXED
  20.       #ENDENABLE
  21.       #PROMPT('&Record Filter:',@S255),%RecordFilter
  22.       #ENABLE(%PrimaryKey)
  23.         #PROMPT('Range Limit &Field:',COMPONENT(%PrimaryKey)),%RangeField
  24.         #ENABLE(%RangeField)
  25.           #PROMPT('Range Limit &Type:',DROP('Current Value|Single Value|Range of Values|File Relationship')),%RangeLimitType,DEFAULT('Current Value')
  26.           #BOXED('Range Limit Boundary'),WHERE(%RangeLimitType='Single Value'),AT(,130)
  27.             #PROMPT('&Range Limit Value:',FIELD),%RangeLimit
  28.           #ENDBOXED
  29.           #BOXED('Range Limit Boundaries'),WHERE(%RangeLimitType='Range of Values'),AT(,130)
  30.             #PROMPT('&Low Limit Value:',FIELD),%RangeLow
  31.             #PROMPT('&High Limit Value:',FIELD),%RangeHigh
  32.           #ENDBOXED
  33.           #BOXED('Range Limiting File'),WHERE(%RangeLimitType='File Relationship'),AT(,130)
  34.             #PROMPT('&Related File:',FILE),%RangeFile
  35.           #ENDBOXED
  36.         #ENDENABLE
  37.       #ENDENABLE
  38.       #BUTTON('&Reset Fields'),MULTI(%ResetFields,%ResetField),AT(10,,180),HLP('~TPLControlBrowseBox_Reset_Fields')
  39.         #PROMPT('&Reset Field:',FIELD),%ResetField
  40.       #ENDBUTTON
  41.       #ENABLE(%PrimaryKey)
  42.         #BUTTON('&Scroll Bar Behavior'),AT(10,,180),HLP('~TPLControlBrowseBox_Scroll_Bar_Behavior')
  43.           #PROMPT('&Scroll Bar Type:',DROP('Fixed Thumb|Movable Thumb')),%ScrollBehavior,DEFAULT('Fixed Thumb')
  44.           #ENABLE(%ScrollBehavior='Movable Thumb')
  45.             #PROMPT('&Key Distribution:',DROP('Alpha|Last Names|Custom|Runtime')),%ScrollKeyDistribution,DEFAULT('Alpha')
  46.             #ENABLE(%ScrollKeyDistribution='Custom')
  47.               #BUTTON('&Custom Key Distribution'),MULTI(%CustomKeyDistribution,%KeyDistributionValue),AT(10,,180),HLP('~TPLControlBrowseBox_Scroll_Bar_Behavior')
  48.                 #PROMPT('&Key Value:',@S10),%KeyDistributionValue,REQ
  49.               #ENDBUTTON
  50.             #ENDENABLE
  51.             #ENABLE(%ScrollKeyDistribution='Runtime')
  52.               #BUTTON('Runtime Distribution Parameters'),AT(10,,180),HLP('~TPLControlBrowseBox_Scroll_Bar_Behavior')
  53.                 #DISPLAY('If the free key element is a string (or')
  54.                 #DISPLAY('CSTRING, PSTRING, etc.), you may customize')
  55.                 #DISPLAY('the characters that are used to compute the')
  56.                 #DISPLAY('scroll bar''s stop points.  If the free key')
  57.                 #DISPLAY('element is numeric, these check will not be used.')
  58.                 #DISPLAY('')
  59.                 #BOXED('Please check the appropriate boxes.')
  60.                   #PROMPT('Use alpha characters',CHECK),%ScrollAlpha,DEFAULT(1),AT(10,,180)
  61.                   #PROMPT('Use numeric characters',CHECK),%ScrollNumeric,AT(10,,180)
  62.                   #PROMPT('Use other keyboard characters',CHECK),%ScrollAlt,AT(10,,180)
  63.                 #ENDBOXED
  64.               #ENDBUTTON
  65.             #ENDENABLE
  66.           #ENDENABLE
  67.         #ENDBUTTON
  68.       #ENDENABLE
  69.     #ENDTAB
  70.     #TAB('&Conditional Behavior'),HLP('~TPLControlBrowseBox_Conditional_Behavior')
  71.       #BUTTON('Conditional Browse Behavior'),MULTI(%SortOrder,%SortCondition & ' - ' & %SortKey),AT(,30),INLINE,HLP('~TPLControlBrowseBox_Conditional_Behavior')
  72.         #PROMPT('Condition:',@S255),%SortCondition
  73.         #PROMPT('Key to Use:',KEY(%Primary)),%SortKey
  74.         #ENABLE(%SortKey)
  75.           #PROMPT('&Locator:',DROP('None|Step|Entry|Incremental')),%SortLocatorType,DEFAULT('Step')
  76.           #BOXED('Entry/Incremental Locator'),WHERE(%SortLocatorType = 'Entry' OR %SortLocatorType = 'Incremental')
  77.             #PROMPT('&Override default locator control',CHECK),%SortOverrideDefaultLocator,AT(10,,180)
  78.             #ENABLE(%SortOverrideDefaultLocator)
  79.               #PROMPT('&New Locator Control:',CONTROL),%SortOverrideLocator,REQ
  80.             #ENDENABLE
  81.           #ENDBOXED
  82.         #ENDENABLE
  83.         #PROMPT('&Record Filter:',@S255),%SortRecordFilter
  84.         #ENABLE(%SortKey)
  85.           #PROMPT('Range Limit &Field:',COMPONENT(%SortKey)),%SortRangeField
  86.           #ENABLE(%SortRangeField)
  87.             #PROMPT('Range Limit &Type:',DROP('Current Value|Single Value|Range of Values|File Relationship')),%SortRangeLimitType,DEFAULT('Current Value')
  88.             #BOXED('Range Limit Boundary'),WHERE(%SortRangeLimitType='Single Value'),AT(,118)
  89.               #PROMPT('&Range Limit Value:',FIELD),%SortRangeLimit
  90.             #ENDBOXED
  91.             #BOXED('Range Limit Boundaries'),WHERE(%SortRangeLimitType='Range of Values'),AT(,118)
  92.               #PROMPT('&Low Limit Value:',FIELD),%SortRangeLow
  93.               #PROMPT('&High Limit Value:',FIELD),%SortRangeHigh
  94.             #ENDBOXED
  95.             #BOXED('Range Limiting File'),WHERE(%SortRangeLimitType='File Relationship'),AT(,118)
  96.               #PROMPT('&Related File:',FILE),%SortRangeFile
  97.             #ENDBOXED
  98.           #ENDENABLE
  99.         #ENDENABLE
  100.         #BUTTON('Reset Fields'),MULTI(%SortResetFields,%SortResetField),AT(10,,180),HLP('~TPLControlBrowseBox_Reset_Fields')
  101.           #PROMPT('&Reset Field:',FIELD),%SortResetField
  102.         #ENDBUTTON
  103.         #ENABLE(%SortKey)
  104.           #BUTTON('Scroll Bar Behavior'),AT(10,,180),HLP('~TPLControlBrowseBox_Scroll_Bar_Behavior')
  105.             #PROMPT('Scroll Bar Type:',DROP('Fixed Thumb|Movable Thumb')),%SortScrollBehavior,DEFAULT('Fixed Thumb')
  106.             #ENABLE(%SortScrollBehavior='Movable Thumb')
  107.               #PROMPT('Key Distribution:',DROP('Alpha|Last Names|Custom|Runtime')),%SortScrollKeyDistribution,DEFAULT('Alpha')
  108.               #ENABLE(%SortScrollKeyDistribution='Custom')
  109.                 #BUTTON('Custom Key Distribution'),MULTI(%SortCustomKeyDistribution,%SortKeyDistributionValue),AT(10,,180),HLP('~TPLControlBrowseBox_Scroll_Bar_Behavior')
  110.                   #PROMPT('Key Value:',@S10),%SortKeyDistributionValue,REQ
  111.                 #ENDBUTTON
  112.               #ENDENABLE
  113.               #ENABLE(%SortScrollKeyDistribution='Runtime')
  114.                 #BUTTON('Runtime Distribution Parameters'),AT(10,,180),HLP('~TPLControlBrowseBox_Scroll_Bar_Behavior')
  115.                   #DISPLAY('If the free key element is a string (or')
  116.                   #DISPLAY('CSTRING, PSTRING, etc.), you may customize')
  117.                   #DISPLAY('the characters that are used to compute the')
  118.                   #DISPLAY('scroll bar''s stop points.  If the free key')
  119.                   #DISPLAY('element is numeric, these check will not be used.')
  120.                   #DISPLAY('')
  121.                   #BOXED('Please check the appropriate boxes.')
  122.                     #PROMPT('Use alpha characters',CHECK),%SortScrollAlpha,DEFAULT(1),AT(10,,180)
  123.                     #PROMPT('Use numeric characters',CHECK),%SortScrollNumeric,AT(10,,180)
  124.                     #PROMPT('Use other keyboard characters',CHECK),%SortScrollAlt,AT(10,,180)
  125.                   #ENDBOXED
  126.                 #ENDBUTTON
  127.               #ENDENABLE
  128.             #ENDENABLE
  129.           #ENDBUTTON
  130.         #ENDENABLE
  131.       #ENDBUTTON
  132.     #ENDTAB
  133.     #TAB('&Hot Fields'),HLP('~TPLControlBrowseBox_Hot_Fields')
  134.       #BUTTON('"Hot" Fields'),MULTI(%HotFields,%HotField),AT(,30),INLINE,HLP('~TPLControlBrowseBox_Hot_Fields')
  135.         #PROMPT('Hot Field:',FIELD),%HotField,REQ
  136.         #PROMPT('BIND Field',CHECK),%HotFieldBound
  137.       #ENDBUTTON
  138.     #ENDTAB
  139.     #TAB('&Colors'),WHERE(%ControlHasColor),HLP('~TPLControlBrowseBox_Colors')
  140.       #PREPARE
  141.         #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  142.       #ENDPREPARE
  143.       #BUTTON('Customize Colors'),FROM(%ControlField,%ControlField),AT(,30),INLINE,WHERE(%ControlFieldHasColor),HLP('~TPLControlBrowseBox_Colors')
  144.         #PREPARE
  145.           #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  146.         #ENDPREPARE
  147.         #BOXED('Default Colors')
  148.           #PROMPT('&Foreground Normal:',COLOR),%ControlFieldForegroundNormal,DEFAULT(-1)
  149.           #PROMPT('&Background Normal:',COLOR),%ControlFieldBackgroundNormal,DEFAULT(-1)
  150.           #PROMPT('&Foreground Selected:',COLOR),%ControlFieldForegroundSelected,DEFAULT(-1)
  151.           #PROMPT('&Background Selected:',COLOR),%ControlFieldBackgroundSelected,DEFAULT(-1)
  152.         #ENDBOXED
  153.         #BOXED('Conditional Color Assignments')
  154.           #BUTTON('Conditional Color Assignments'),MULTI(%ConditionalColors,%ColorCondition),INLINE,HLP('~TPLControlBrowseBox_Colors')
  155.             #PROMPT('&Condition:',@S255),%ColorCondition
  156.             #PROMPT('&Foreground Normal:',COLOR),%ConditionalControlFieldForegroundNormal,DEFAULT(-1)
  157.             #PROMPT('&Background Normal:',COLOR),%ConditionalControlFieldBackgroundNormal,DEFAULT(-1)
  158.             #PROMPT('&Foreground Selected:',COLOR),%ConditionalControlFieldForegroundSelected,DEFAULT(-1)
  159.             #PROMPT('&Background Selected:',COLOR),%ConditionalControlFieldBackgroundSelected,DEFAULT(-1)
  160.           #ENDBUTTON
  161.         #ENDBOXED
  162.       #ENDBUTTON
  163.     #ENDTAB
  164.     #TAB('&Icons'),WHERE(%ControlHasIcon),HLP('~TPLControlBrowseBox_Icons')
  165.       #PREPARE
  166.         #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  167.       #ENDPREPARE
  168.       #BUTTON('&Customize BrowseBox Icons'),FROM(%ControlField,%ControlField & ' - ' & %ControlFieldIcon),AT(,30),HLP('~TPLControlBrowseBox_Icons'),INLINE,WHERE(%ControlFieldHasIcon)
  169.         #PREPARE
  170.           #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  171.         #ENDPREPARE
  172.         #BOXED('Default Icon')
  173.           #PROMPT('Icon:',@S40),%ControlFieldIcon
  174.         #ENDBOXED
  175.         #BOXED('Conditional Icon Usage')
  176.           #BUTTON('&Conditional Icon Usage'),MULTI(%ConditionalIcons,%IconCondition),INLINE,HLP('~TPLControlBrowseBox_Icons')
  177.             #PROMPT('&Condition:',@S255),%IconCondition
  178.             #PROMPT('Icon:',@S40),%ConditionalControlFieldIcon
  179.           #ENDBUTTON
  180.         #ENDBOXED
  181.       #ENDBUTTON
  182.     #ENDTAB
  183.     #TAB('&Totaling'),HLP('~TPLControlBrowseBox_Totaling')
  184.       #BUTTON('Browse Totaling'),MULTI(%BrowseTotals,%BrowseTotalTarget & ' (' & %BrowseTotalType & ')'),AT(,30),INLINE
  185.         #PROMPT('Total Target Field:',FIELD),%BrowseTotalTarget,REQ
  186.         #PROMPT('Total Type:',DROP('Count|Sum|Average')),%BrowseTotalType
  187.         #ENABLE(%BrowseTotalType <> 'Count'),CLEAR
  188.           #PROMPT('Field To Total:',FIELD),%BrowseTotalField,REQ
  189.         #ENDENABLE
  190.         #PROMPT('Total Based On:',DROP('Each Record Read|Specified Condition')),%BrowseTotalBasedOn
  191.         #ENABLE(%BrowseTotalBasedOn = 'Specified Condition'),CLEAR
  192.           #PROMPT('Total Condition:',@S255),%BrowseTotalCondition,REQ
  193.         #ENDENABLE
  194.       #ENDBUTTON
  195.     #ENDTAB
  196.   #ENDSHEET
  197. #ENDBUTTON
  198. #CLASS('Before Filter',%ActiveTemplateInstanceDescription & ' - Validate Record before Filter Code')
  199. #CLASS('Before Range Limits',%ActiveTemplateInstanceDescription & ' - Validate Record before Range Limit Code')
  200. #CLASS('Format Browse','Format a variable in the ' & %ActiveTemplateInstanceDescription)
  201. #AT(%CustomGlobalDeclarations)
  202.   #INSERT(%FileControlSetFlags)
  203. #ENDAT
  204. #ATSTART
  205. #MESSAGE('Initializing Browse',3)
  206. #INSERT(%FileControlInitialize)
  207. #DECLARE(%InstancePrefix)
  208. #SET(%InstancePrefix,'BRW' & %ActiveTemplateInstance & ':')
  209. #DECLARE(%ListView)
  210. #SET(%ListView,%InstancePrefix & ':View:Browse')
  211. #DECLARE(%VerticalScrollBarFound)
  212. #DECLARE(%ListControl)
  213. #DECLARE(%UseValidateRoutine)
  214. #DECLARE(%BeginningOffset)
  215. #DECLARE(%EndingOffset)
  216. #SET(%VerticalScrollBarFound,%False)
  217. #FOR(%Control),WHERE(%ControlInstance = %ActiveTemplateInstance)
  218.   #SET(%ListControl,%Control)
  219.   #IF(EXTRACT(%ControlStatement,'VSCROLL'))
  220.     #SET(%VerticalScrollBarFound,%True)
  221.   #ELSIF(EXTRACT(%ControlStatement,'HVSCROLL'))
  222.     #SET(%VerticalScrollBarFound,%True)
  223.   #ENDIF
  224. #ENDFOR
  225. #DECLARE(%ListViewBoundField),UNIQUE
  226. #DECLARE(%BrowseAccessID),MULTI
  227. #DECLARE(%BrowseTotalKeys)
  228. #DECLARE(%BrowseKey,%BrowseAccessID)
  229. #DECLARE(%BrowsePrefix,%BrowseAccessID)
  230. #DECLARE(%BrowseCondition,%BrowseAccessID)
  231. #DECLARE(%BrowseRecordFilter,%BrowseAccessID)
  232. #DECLARE(%BrowseRangeField,%BrowseAccessID)
  233. #DECLARE(%BrowseRangeLimitType,%BrowseAccessID)
  234. #DECLARE(%BrowseRangeLimit,%BrowseAccessID)
  235. #DECLARE(%BrowseRangeHigh,%BrowseAccessID)
  236. #DECLARE(%BrowseRangeLow,%BrowseAccessID)
  237. #DECLARE(%BrowseRangeFile,%BrowseAccessID)
  238. #DECLARE(%BrowseRangeLimitField,%BrowseAccessID),MULTI
  239. #DECLARE(%BrowseRangeLimitValue,%BrowseRangeLimitField)
  240. #DECLARE(%BrowseResetField,%BrowseAccessID),UNIQUE
  241. #DECLARE(%BrowseFreeElement,%BrowseAccessID)
  242. #DECLARE(%BrowseFilterStatement,%BrowseAccessID)
  243. #DECLARE(%BrowseLocatorType,%BrowseAccessID)
  244. #DECLARE(%BrowseLocatorName,%BrowseAccessID)
  245. #DECLARE(%BrowseLocatorField,%BrowseAccessID)
  246. #DECLARE(%BrowseLocatorControl,%BrowseAccessID)
  247. #DECLARE(%BrowseScrollBehavior,%BrowseAccessID)
  248. #DECLARE(%BrowseScrollKeyDistribution,%BrowseAccessID)
  249. #DECLARE(%BrowseScrollParameters,%BrowseAccessID)
  250. #DECLARE(%BrowseKeyDistributionValue,%BrowseAccessID),MULTI
  251. #DECLARE(%BrowseKeyDistributionCount,%BrowseAccessID)
  252. #DECLARE(%ListQueue)
  253. #DECLARE(%IconList),UNIQUE
  254. #DECLARE(%IconListType,%IconList)
  255. #DECLARE(%QueueField),MULTI
  256. #DECLARE(%QueueFieldAssignment,%QueueField)
  257. #DECLARE(%QueueFieldHasColor,%QueueField)
  258. #DECLARE(%QueueFieldHasIcon,%QueueField)
  259. #DECLARE(%QueueFieldHasTree,%QueueField)
  260. #FIX(%Key,%PrimaryKey)
  261. #FIX(%Control,%ListControl)
  262. #SET(%ListQueue,EXTRACT(%ControlStatement,'FROM',1))
  263. #FOR(%ControlField)
  264.   #SET(%ValueConstruct,%ControlField)
  265.   #IF(INSTRING('[',%ValueConstruct,1,1))
  266.     #INSERT(%ReplaceCharacter,'[','_')
  267.     #INSERT(%ReplaceCharacter,',','_')
  268.     #INSERT(%ReplaceCharacter,']','_')
  269.   #ENDIF
  270.   #ADD(%QueueField,%InstancePrefix & ':' & %ValueConstruct)
  271.   #SET(%QueueFieldAssignment,%ControlField)
  272.   #SET(%QueueFieldHasColor,%ControlFieldHasColor)
  273.   #SET(%QueueFieldHasIcon,%ControlFieldHasIcon)
  274.   #IF(%ControlFieldHasIcon)
  275.     #IF(%ControlFieldIcon)
  276.       #INSERT(%AddBrowseIcon,%ControlFieldIcon)
  277.       #FOR(%ConditionalIcons)
  278.         #INSERT(%AddBrowseIcon,%ConditionalControlFieldIcon)
  279.       #ENDFOR
  280.     #ENDIF
  281.   #ENDIF
  282. #ENDFOR
  283. #FOR(%HotFields)
  284.   #SET(%ValueConstruct,%InstancePrefix & ':' & %HotField)
  285.   #FIX(%QueueField,%ValueConstruct)
  286.   #IF(%QueueField <> %ValueConstruct)
  287.     #ADD(%QueueField,%ValueConstruct)
  288.     #SET(%QueueFieldAssignment,%HotField)
  289.   #ENDIF
  290. #ENDFOR
  291. #FIX(%File,%Primary)
  292. #FIX(%Key,%FilePrimaryKey)
  293. #FOR(%KeyField)
  294.   #SET(%ValueConstruct,%InstancePrefix & ':' & %KeyField)
  295.   #FIX(%QueueField,%ValueConstruct)
  296.   #IF(%QueueField <> %ValueConstruct)
  297.     #ADD(%QueueField,%ValueConstruct)
  298.     #SET(%QueueFieldAssignment,%KeyField)
  299.   #ENDIF
  300. #ENDFOR
  301. #INSERT(%SetupBrowseBehavior)
  302. #ENDAT
  303. #!-------------------------------------------------------------------------
  304. #AT(%DataSectionBeforeWindow)
  305.   #MESSAGE('BrowseBox Control Declarations',3)
  306.  
  307. #INSERT(%ConstructView)
  308.  
  309. %[20]ListQueue QUEUE,PRE()                      #<! Browsing Queue
  310.   #FOR(%QueueField)                             #! FOR each field in list
  311.     #FIND(%Field,%QueueFieldAssignment)         #! FIND Field to control field
  312.     #IF(%FieldType = 'GROUP')                   #! IF component is a group
  313. %[22]QueueField STRING(SIZE(%QueueFieldAssignment))#<! Queue Display field
  314.     #ELSE                                       #! ELSE (component NOT a group)
  315. %[22]QueueField LIKE(%QueueFieldAssignment) #<! Queue Display field
  316.     #ENDIF                                      #! END (IF component is a group)
  317.     #IF(%QueueFieldHasColor)
  318. %QueueField:NormalFG LONG                            #<! Normal Foreground
  319. %QueueField:NormalBG LONG                            #<! Normal Background
  320. %QueueField:SelectedFG LONG                            #<! Selected Foreground
  321. %QueueField:SelectedBG LONG                            #<! Selected Background
  322.     #ENDIF
  323.     #IF(%QueueFieldHasIcon)
  324. %QueueField:Icon SHORT                          #<! Field Icon
  325.     #ENDIF
  326.   #ENDFOR                                       #! END (FOR each field in list)
  327.   #SET(%ValueConstruct,%InstancePrefix & ':Mark')
  328. %[22]ValueConstruct BYTE                        #<! Queue POSITION information
  329. #EMBED(%EndOfListQueue,'End of list QUEUE'),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  330.   #SET(%ValueConstruct,%InstancePrefix & ':Position')
  331. %[22]ValueConstruct STRING(512)                 #<! Queue POSITION information
  332.                      END                        #<! END (Browsing Queue)
  333.   #FIX(%File,%Primary)
  334.   #IF(%VerticalScrollBarFound)
  335.     #SET(%ValueConstruct,%InstancePrefix & ':CurrentScroll')
  336. %[20]ValueConstruct BYTE                        #<! Queue position of scroll thumb
  337.     #SET(%ValueConstruct,%InstancePrefix & ':ScrollRecordCount')
  338. %[20]ValueConstruct LONG                        #<! Queue position of scroll thumb
  339.   #ENDIF
  340.   #FOR(%BrowseAccessID)
  341.     #IF(%BrowseKey)
  342.       #FIX(%Key,%BrowseKey)
  343.       #IF(%BrowseRangeField AND %BrowseRangeLimitType <> 'File Relationship')
  344.         #FOR(%KeyField)
  345.           #IF(UPPER(%KeyField)=UPPER(%BrowseRangeField))
  346.             #IF(%BrowseRangeLimitType <> 'Current Value')
  347.               #BREAK
  348.             #ENDIF
  349.           #ENDIF
  350.           #FIX(%Field,%KeyField)                        #! Fix to component of key
  351.           #SET(%ValueConstruct,%BrowsePrefix & ':Save:' & %KeyField)
  352.           #IF(%FieldType = 'GROUP')                     #! IF component is a group
  353. %[20]ValueConstruct LIKE(%KeyField),PRE(SAV)        #<! Save Range Limit Group
  354.           #ELSE                                         #! Else component NOT a group
  355. %[20]ValueConstruct LIKE(%KeyField)                 #<! Save Range Limit Field
  356.           #ENDIF                                        #! EndIf component is a group
  357.           #IF(UPPER(%KeyField)=UPPER(%BrowseRangeField))
  358.             #BREAK
  359.           #ENDIF
  360.         #ENDFOR
  361.       #ENDIF
  362.       #IF(%BrowseLocatorType='Incremental')
  363.         #SET(%ValueConstruct,%BrowsePrefix & ':LocatorValue')
  364. %[20]ValueConstruct STRING(30)    #<! Flag for Range/Filter test
  365.         #SET(%ValueConstruct,%BrowsePrefix & ':LocatorLength')
  366. %[20]ValueConstruct BYTE                         #<! Flag for Range/Filter test
  367.       #ELSIF(%BrowseLocatorType='Entry')
  368.         #SET(%ValueConstruct,%BrowsePrefix & ':LocatorValue')
  369. %[20]ValueConstruct STRING(30)    #<! Flag for Range/Filter test
  370.       #ENDIF
  371.       #IF(%VerticalScrollBarFound AND %BrowseFreeElement)
  372.         #IF(%BrowseScrollKeyDistribution='Custom')
  373.           #SET(%ValueConstruct,%BrowsePrefix & ':KeyDistribution')
  374. %[20]ValueConstruct LIKE(%BrowseFreeElement),DIM(%BrowseKeyDistributionCount)
  375.         #ELSIF(%BrowseScrollKeyDistribution='Runtime')
  376.           #SET(%ValueConstruct,%BrowsePrefix & ':KeyDistribution')
  377. %[20]ValueConstruct LIKE(%BrowseFreeElement),DIM(100)
  378.           #SET(%ValueConstruct,%BrowsePrefix & ':LowValue')
  379. %[20]ValueConstruct LIKE(%BrowseFreeElement)     #<! Queue position of scroll thumb
  380.           #SET(%ValueConstruct,%BrowsePrefix & ':HighValue')
  381. %[20]ValueConstruct LIKE(%BrowseFreeElement)     #<! Queue position of scroll thumb
  382.         #ENDIF
  383.       #ENDIF
  384.     #ENDIF
  385.     #FOR(%BrowseResetField)
  386.       #SET(%ValueConstruct,%BrowsePrefix & ':Reset:' & %BrowseResetField)
  387. %[20]ValueConstruct LIKE(%BrowseResetField)
  388.     #ENDFOR
  389.   #ENDFOR
  390.   #IF(%EnableQuickScan)
  391.     #SET(%ValueConstruct,%InstancePrefix & ':QuickScan')
  392. %[20]ValueConstruct BYTE                         #<! Flag for Range/Filter test
  393.   #ENDIF
  394.   #SET(%ValueConstruct,%InstancePrefix & ':CurrentEvent')
  395. %[20]ValueConstruct LONG                         #<!
  396.   #SET(%ValueConstruct,%InstancePrefix & ':CurrentChoice')
  397. %[20]ValueConstruct LONG                         #<!
  398.   #SET(%ValueConstruct,%InstancePrefix & ':RecordCount')
  399. %[20]ValueConstruct LONG                         #<!
  400.   #SET(%ValueConstruct,%InstancePrefix & ':SortOrder')
  401. %[20]ValueConstruct BYTE                         #<! 
  402.   #SET(%ValueConstruct,%InstancePrefix & ':LocateMode')
  403. %[20]ValueConstruct BYTE                         #<! 
  404.   #SET(%ValueConstruct,%InstancePrefix & ':RefreshMode')
  405. %[20]ValueConstruct BYTE                         #<! 
  406.   #SET(%ValueConstruct,%InstancePrefix & ':LastSortOrder')
  407. %[20]ValueConstruct BYTE                         #<! 
  408.   #SET(%ValueConstruct,%InstancePrefix & ':FillDirection')
  409. %[20]ValueConstruct BYTE                         #<! 
  410.   #SET(%ValueConstruct,%InstancePrefix & ':AddQueue')
  411. %[20]ValueConstruct BYTE                         #<! 
  412.   #SET(%ValueConstruct,%InstancePrefix & ':Changed')
  413. %[20]ValueConstruct BYTE                         #<! 
  414.   #SET(%ValueConstruct,%InstancePrefix & ':RecordStatus')
  415. %[20]ValueConstruct BYTE                         #<! Flag for Range/Filter test
  416.   #SET(%ValueConstruct,%InstancePrefix & ':ItemsToFill')
  417. %[20]ValueConstruct LONG                         #<! Controls records retrieved
  418.   #SET(%ValueConstruct,%InstancePrefix & ':MaxItemsInList')
  419. %[20]ValueConstruct LONG                         #<! Retrieved after window opened
  420.   #SET(%ValueConstruct,%InstancePrefix & ':HighlightedPosition')
  421. %[20]ValueConstruct STRING(512)                  #<! POSITION of located record
  422.   #SET(%ValueConstruct,%InstancePrefix & ':NewSelectPosted')
  423. %[20]ValueConstruct BYTE                         #<! Queue position of located record
  424.   #FOR(%BrowseTotals)
  425.     #CASE(%BrowseTotalType)
  426.     #OF('Count')
  427.       #SET(%ValueConstruct,%InstancePrefix & ':' & %BrowseTotalTarget & ':Cnt:Value')
  428. %[20]ValueConstruct LONG                         #<! Queue position of scroll thumb
  429.       #SET(%ValueConstruct,%InstancePrefix & ':' & %BrowseTotalTarget & ':Cnt:Temp')
  430. %[20]ValueConstruct LONG                         #<! Queue position of scroll thumb
  431.     #OF('Sum')
  432.       #SET(%ValueConstruct,%InstancePrefix & ':' & %BrowseTotalTarget & ':Sum:Value')
  433. %[20]ValueConstruct REAL                         #<! Queue position of scroll thumb
  434.       #SET(%ValueConstruct,%InstancePrefix & ':' & %BrowseTotalTarget & ':Sum:Temp')
  435. %[20]ValueConstruct REAL                         #<! Queue position of scroll thumb
  436.     #OF('Average')
  437.       #SET(%ValueConstruct,%InstancePrefix & ':' & %BrowseTotalTarget & ':Cnt:Value')
  438. %[20]ValueConstruct LONG                         #<! Queue position of scroll thumb
  439.       #SET(%ValueConstruct,%InstancePrefix & ':' & %BrowseTotalTarget & ':Cnt:Temp')
  440. %[20]ValueConstruct LONG                         #<! Queue position of scroll thumb
  441.       #SET(%ValueConstruct,%InstancePrefix & ':' & %BrowseTotalTarget & ':Sum:Value')
  442. %[20]ValueConstruct REAL                         #<! Queue position of scroll thumb
  443.       #SET(%ValueConstruct,%InstancePrefix & ':' & %BrowseTotalTarget & ':Sum:Temp')
  444. %[20]ValueConstruct REAL                         #<! Queue position of scroll thumb
  445.     #ENDCASE
  446.   #ENDFOR
  447.   #SET(%ValueConstruct,%InstancePrefix & ':PopupText')
  448. %[20]ValueConstruct STRING(128)                  #<!
  449. #ENDAT
  450. #!-------------------------------------------------------------------------
  451. #AT(%AfterWindowOpening)
  452. %InstancePrefix:AddQueue = True
  453. %InstancePrefix:RecordCount = 0
  454. #FIX(%File,%Primary)
  455. #SUSPEND
  456. IF LocalRequest <> SelectRecord
  457.   #EMBED(%BrowsePrepNormal,'Browse Preparation, Request Normal Operation')
  458. #?ELSE
  459.   #EMBED(%BrowsePrepSelectRecord,'Browse Preparation, Request to Select Record')
  460. END
  461. #RESUME
  462. #FOR(%BrowseAccessID)
  463.   #IF(%BrowseScrollKeyDistribution='Custom')
  464.     #FOR(%BrowseKeyDistributionValue)
  465.       #SET(%ValueConstruct,INSTANCE(%BrowseKeyDistributionValue))
  466. %BrowsePrefix:KeyDistribution[%ValueConstruct]=%BrowseKeyDistributionValue
  467.     #ENDFOR
  468.   #ENDIF
  469. #ENDFOR
  470. #FOR(%HotFields),WHERE(%HotFieldBound)
  471.   #FIND(%Field,%HotField)
  472.   #IF(NOT %FieldFile OR %FieldName)
  473.     #FIX(%ListViewBoundField,%HotField)
  474.     #IF(NOT %ListViewBoundField)
  475. BIND('%HotField',%HotField)
  476.     #ENDIF
  477.   #ENDIF
  478. #ENDFOR
  479. #FOR(%ListViewBoundField)
  480.   #FIND(%Field,%ListViewBoundField)
  481.   #IF(NOT %FieldFile OR %FieldName)
  482. BIND('%ListViewBoundField',%ListViewBoundField)
  483.   #ENDIF
  484. #ENDFOR
  485. #FOR(%IconList),WHERE(%IconListType <> 'Variable')
  486.   #SET(%ValueConstruct,INSTANCE(%IconList))
  487.   #IF(%IconListType = 'Built-In')
  488. %ListControl{Prop:IconList,%ValueConstruct} = %IconList
  489.   #ELSIF(%IconListType = 'File')
  490. %ListControl{Prop:IconList,%ValueConstruct} = '%IconList'
  491.   #ENDIF
  492. #ENDFOR
  493. #ENDAT
  494. #!-------------------------------------------------------------------------
  495. #AT(%PrepareAlerts)
  496. %ListControl{Prop:Alrt,252} = MouseLeft2
  497. #FOR(%BrowseAccessID)
  498.   #IF(%BrowseLocatorType = 'Incremental')
  499. %ListControl{Prop:Alrt,250} = BSKey
  500. %ListControl{Prop:Alrt,250} = SpaceKey
  501.     #BREAK
  502.   #ENDIF
  503. #ENDFOR
  504. #ENDAT
  505. #!-------------------------------------------------------------------------
  506. #AT(%ControlEventHandling,%ListControl,'NewSelection')
  507. DO %InstancePrefix:NewSelection
  508. #ENDAT
  509. #!-------------------------------------------------------------------------
  510. #AT(%ControlEventHandling,%ListControl,'ScrollUp')
  511. DO %InstancePrefix:ProcessScroll
  512. #ENDAT
  513. #!-------------------------------------------------------------------------
  514. #AT(%ControlEventHandling,%ListControl,'ScrollDown')
  515. DO %InstancePrefix:ProcessScroll
  516. #ENDAT
  517. #!-------------------------------------------------------------------------
  518. #AT(%ControlEventHandling,%ListControl,'PageUp')
  519. DO %InstancePrefix:ProcessScroll
  520. #ENDAT
  521. #!-------------------------------------------------------------------------
  522. #AT(%ControlEventHandling,%ListControl,'ScrollDrag')
  523. #IF(%VerticalScrollBarFound)
  524. DO %InstancePrefix:ScrollDrag
  525. #ENDIF
  526. #ENDAT
  527. #!-------------------------------------------------------------------------
  528. #AT(%ControlEventHandling,%ListControl,'PageDown')
  529. DO %InstancePrefix:ProcessScroll
  530. #ENDAT
  531. #!-------------------------------------------------------------------------
  532. #AT(%ControlEventHandling,%ListControl,'ScrollTop')
  533. DO %InstancePrefix:ProcessScroll
  534. #ENDAT
  535. #!-------------------------------------------------------------------------
  536. #AT(%ControlEventHandling,%ListControl,'ScrollBottom')
  537. DO %InstancePrefix:ProcessScroll
  538. #ENDAT
  539. #!-------------------------------------------------------------------------
  540. #AT(%ControlEventHandling,%ListControl,'AlertKey')
  541. DO %InstancePrefix:AlertKey
  542. #ENDAT
  543. #!-------------------------------------------------------------------------
  544. #AT(%ControlEventHandling)
  545. #IF(%ControlEvent = 'Accepted')
  546.   #FIND(%BrowseLocatorControl,%Control)
  547.   #IF(%BrowseLocatorType = 'Entry' OR %BrowseLocatorType = 'Incremental')
  548. IF ForceRefresh = False
  549.   IF %InstancePrefix:RecordCount
  550.     IF %BrowseLocatorName
  551.       UPDATE(%BrowseLocatorControl)
  552.       #FIX(%File,%Primary)
  553.       #FIX(%Key,%BrowseKey)
  554.       #SET(%ValueConstruct,%False)
  555.       #FOR(%KeyField)
  556.         #IF(%ValueConstruct)
  557.           #IF(%KeyFieldSequence = 'ASCENDING')
  558.       CLEAR(%KeyField)
  559.           #ELSE
  560.       CLEAR(%KeyField,1)
  561.           #ENDIF
  562.         #ELSE
  563.           #IF(%KeyField = %BrowseLocatorName)
  564.             #SET(%ValueConstruct,%True)
  565.           #ENDIF
  566.         #ENDIF
  567.       #ENDFOR
  568.       %InstancePrefix:LocateMode = LocateOnValue
  569.       DO %InstancePrefix:LocateRecord
  570.       #IF(%BrowseLocatorType = 'Incremental')
  571.       %BrowsePrefix:LocatorValue = %BrowseLocatorName
  572.       %BrowsePrefix:LocatorLength = LEN(CLIP(%BrowseLocatorName))
  573.       #ENDIF
  574.       SELECT(%ListControl)
  575.       DO %InstancePrefix:PostNewSelection
  576.     END
  577.   END
  578. ELSE
  579.   %InstancePrefix:RefreshMode = RefreshOnQueue
  580.   DO %InstancePrefix:RefreshPage
  581. END
  582.   #ENDIF
  583. #ENDIF
  584. #ENDAT
  585. #!-------------------------------------------------------------------------
  586. #AT(%RefreshWindowAfterLookup)
  587. #EMBED(%BeforeControlRefresh,'Before Refresh Window for Browse Box'),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  588. DO %InstancePrefix:SelectSort
  589. #EMBED(%AfterControlRefresh,'After Refresh Window for Browse Box'),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  590. #ENDAT
  591. #!-------------------------------------------------------------------------
  592. #AT(%RefreshWindowBeforeDisplay)
  593. #IF(%VerticalScrollBarFound)
  594. %ListControl{Prop:VScrollPos} = %InstancePrefix:CurrentScroll
  595. #ENDIF
  596. #SUSPEND
  597. #?CASE %InstancePrefix:SortOrder
  598.   #FOR(%BrowseAccessID)
  599.     #SUSPEND
  600. #?OF %BrowseAccessID
  601.       #IF(%BrowseLocatorControl)
  602.         #IF(%BrowseLocatorType = 'Entry')
  603.   %BrowsePrefix:LocatorValue = %BrowseLocatorName
  604.   CLEAR(%BrowseLocatorName)
  605.         #ELSIF(%BrowseLocatorType = 'Incremental')
  606.   %BrowseLocatorName = %BrowsePrefix:LocatorValue
  607.         #ENDIF
  608.       #ENDIF
  609.     #RESUME
  610.   #ENDFOR
  611. #?END
  612. #RESUME
  613. #ENDAT
  614. #!-------------------------------------------------------------------------
  615. #AT(%SyncWindowAfterLookup)
  616. DO %InstancePrefix:GetRecord
  617. #ENDAT
  618. #!-------------------------------------------------------------------------
  619. #AT(%ProcedureRoutines)
  620. #FIX(%File,%Primary)
  621. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':ValidateRecord',3)
  622. #INSERT(%BrowseRoutineValidateRecord)
  623. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':SelectSort',3)
  624. #INSERT(%BrowseRoutineSelectSort)
  625. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':InitializeBrowse',3)
  626. #INSERT(%BrowseRoutineInitializeBrowse)
  627. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':FillBuffer',3)
  628. #INSERT(%BrowseRoutineFillBuffer)
  629. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':FillQueue',3)
  630. #INSERT(%BrowseRoutineFillQueue)
  631. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':PostNewSelection',3)
  632. #INSERT(%BrowseRoutinePostNewSelection)
  633. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':NewSelection',3)
  634. #INSERT(%BrowseRoutineNewSelection)
  635. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':ProcessScroll',3)
  636. #INSERT(%BrowseRoutineProcessScroll)
  637. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':ScrollOne',3)
  638. #INSERT(%BrowseRoutineScrollOne)
  639. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':ScrollPage',3)
  640. #INSERT(%BrowseRoutineScrollPage)
  641. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':ScrollEnd',3)
  642. #INSERT(%BrowseRoutineScrollEnd)
  643. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':AlertKey',3)
  644. #INSERT(%BrowseRoutineAlertKey)
  645. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':ScrollDrag',3)
  646. #INSERT(%BrowseRoutineScrollDrag)
  647. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':FillRecord',3)
  648. #INSERT(%BrowseRoutineFillRecord)
  649. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':LocateRecord',3)
  650. #INSERT(%BrowseRoutineLocateRecord)
  651. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':RefreshPage',3)
  652. #INSERT(%BrowseRoutineRefreshPage)
  653. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':Reset',3)
  654. #INSERT(%BrowseRoutineReset)
  655. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':GetRecord',3)
  656. #INSERT(%BrowseRoutineGetRecord)
  657. #MESSAGE('BrowseBox Routine - ' & %InstancePrefix & ':RestoreResetValues',3)
  658. #INSERT(%BrowseRoutineRestoreResetValues)
  659. #ENDAT
  660. #!-------------------------------------------------------------------------
  661. #GROUP(%AddBrowseIcon,%CurrentIcon)
  662. #IF(UPPER(SUB(%CurrentIcon,1,5)) = 'ICON:')
  663.   #ADD(%IconList,%CurrentIcon)
  664.   #SET(%IconListType,'Built-In')
  665. #ELSIF(SUB(%CurrentIcon,1,1) = '!')
  666.   #SET(%ValueConstruct,SUB(%CurrentIcon,2,LEN(%CurrentIcon)-1))
  667.   #ADD(%IconList,%ValueConstruct)
  668.   #SET(%IconListType,'Variable')
  669. #ELSE
  670.   #ADD(%IconList,%CurrentIcon)
  671.   #SET(%IconListType,'File')
  672. #ENDIF
  673. #!-------------------------------------------------------------------------
  674. #GROUP(%ConstructView)
  675. #FIX(%File,%Primary)
  676. %[20]ListView VIEW(%Primary)
  677. #FOR(%QueueField)
  678.   #FIX(%Field,%QueueFieldAssignment)
  679.   #IF(%Field)
  680. %[22]Null PROJECT(%Field)
  681.   #ENDIF
  682. #ENDFOR
  683. #FOR(%Secondary),WHERE(%SecondaryTo=%Primary)
  684.   #INSERT(%ConstructViewProjectSecondary,%Primary,%Secondary)
  685. #ENDFOR
  686. #FOR(%Secondary),WHERE(%SecondaryTo=%Primary)
  687.   #INSERT(%ConstructViewJoinSecondary,%Primary,%Secondary)
  688. #ENDFOR
  689. %[20]Null END
  690. #!-------------------------------------------------------------------------
  691. #GROUP(%ConstructViewJoinSecondary,%CurrentPrimary,%CurrentSecondary)
  692. #DECLARE(%JoinDeclaration)
  693. #SET(%JoinDeclaration,'JOIN(')
  694. #FIX(%File,%CurrentSecondary)
  695. #FIX(%Relation,%CurrentPrimary)
  696. #SET(%JoinDeclaration,%JoinDeclaration & %FileKey)
  697. #FOR(%RelationKeyField),WHERE(%RelationKeyFieldLink AND %RelationKeyField)
  698.   #SET(%JoinDeclaration,%JoinDeclaration & ',' & %RelationKeyField)
  699.   #IF(%FileRelationType = '1:MANY')
  700.     #IF(%InstancePrefix)
  701.       #SET(%ValueConstruct,%InstancePrefix & ':' & %RelationKeyFieldLink)
  702.       #FIX(%QueueField,%ValueConstruct)
  703.       #IF(%QueueField <> %ValueConstruct)
  704.         #ADD(%QueueField,%ValueConstruct)
  705.         #SET(%QueueFieldAssignment,%RelationKeyFieldLink)
  706.       #ENDIF
  707.     #ENDIF
  708.   #ENDIF
  709. #ENDFOR
  710. #SET(%JoinDeclaration,%JoinDeclaration & ')')
  711. %[20]Null %JoinDeclaration
  712. #FOR(%QueueField)
  713.   #FIX(%Field,%QueueFieldAssignment)
  714.   #IF(%Field)
  715. %[22]Null PROJECT(%Field)
  716.   #ENDIF
  717. #ENDFOR
  718. #FOR(%Secondary),WHERE(%SecondaryTo=%CurrentSecondary)
  719.   #INSERT(%ConstructViewProjectSecondary,%CurrentSecondary,%Secondary)
  720. #ENDFOR
  721. #FOR(%Secondary),WHERE(%SecondaryTo=%CurrentSecondary)
  722.   #INSERT(%ConstructViewJoinSecondary,%CurrentSecondary,%Secondary)
  723. #ENDFOR
  724. %[20]Null END
  725. #!-------------------------------------------------------------------------
  726. #GROUP(%ConstructViewProjectSecondary,%CurrentPrimary,%CurrentSecondary)
  727. #FIX(%File,%CurrentSecondary)
  728. #FIX(%Relation,%CurrentPrimary)
  729. #FOR(%RelationKeyField),WHERE(%RelationKeyFieldLink AND %RelationKeyField)
  730.   #FIX(%QueueField,%RelationKeyField)
  731.   #IF(NOT %QueueField)
  732. %[20]Null PROJECT(%RelationKeyField)
  733.   #ENDIF
  734. #ENDFOR
  735. #!---------------------------------------------------------------------
  736. #GROUP(%SetupBrowseBehavior)
  737. #EMBED(%TopOfSetupBrowseBehavior,'INTERNAL Top of SetupBrowseBehavior GROUP'),HIDE
  738. #DECLARE(%BrowseFreeElementFound)
  739. #DECLARE(%ValidRangeKey)
  740. #DECLARE(%BrowseFiltersExist)
  741. #DECLARE(%FieldIsString)
  742. #FOR(%SortOrder)
  743.   #ADD(%BrowseAccessID,ITEMS(%BrowseAccessID)+1)
  744.   #SET(%BrowseKey,%SortKey)
  745.   #SET(%BrowsePrefix,%InstancePrefix & ':Sort' & %BrowseAccessID)
  746.   #SET(%BrowseCondition,%SortCondition)
  747.   #SET(%BrowseRecordFilter,%SortRecordFilter)
  748.   #FOR(%SortResetFields)
  749.     #ADD(%BrowseResetField,%SortResetField)
  750.   #ENDFOR
  751.   #IF(%BrowseKey)
  752.     #SET(%BrowseRangeField,%SortRangeField)
  753.     #SET(%BrowseRangeLimitType,%SortRangeLimitType)
  754.     #SET(%BrowseRangeLimit,%SortRangeLimit)
  755.     #SET(%BrowseRangeHigh,%SortRangeHigh)
  756.     #SET(%BrowseRangeLow,%SortRangeLow)
  757.     #SET(%BrowseRangeFile,%SortRangeFile)
  758.     #SET(%BrowseLocatorType,%SortLocatorType)
  759.     #IF(%BrowseLocatorType = 'Entry' OR %BrowseLocatorType = 'Incremental')
  760.       #IF(%SortOverrideDefaultLocator)
  761.     #SET(%BrowseLocatorControl,%SortOverrideLocator)
  762.       #ENDIF
  763.     #ENDIF
  764.     #IF(%VerticalScrollBarFound)
  765.       #SET(%BrowseScrollBehavior,%SortScrollBehavior)
  766.       #IF(%BrowseScrollBehavior = 'Movable Thumb')
  767.         #SET(%BrowseScrollKeyDistribution,%SortScrollKeyDistribution)
  768.         #IF(%BrowseScrollKeyDistribution = 'Custom')
  769.           #FOR(%SortCustomKeyDistribution)
  770.             #ADD(%BrowseKeyDistributionValue,%SortKeyDistributionValue)
  771.           #ENDFOR
  772.           #SET(%BrowseKeyDistributionCount,ITEMS(%BrowseKeyDistributionValue))
  773.         #ELSIF(%BrowseScrollKeyDistribution = 'Runtime')
  774.           #IF(%SortScrollAlpha)
  775.             #SET(%BrowseScrollParameters,'ScrollSort:AllowAlpha')
  776.             #FIX(%File,%Primary)
  777.             #FIX(%Key,%BrowseKey)
  778.             #IF(NOT %KeyNoCase)
  779.               #SET(%BrowseScrollParameters,%BrowseScrollParameters & '+ScrollSort:CaseSensitive')
  780.             #ENDIF
  781.             #IF(%SortScrollNumeric OR %SortScrollAlt)
  782.               #SET(%BrowseScrollParameters,%BrowseScrollParameters & '+')
  783.             #ENDIF
  784.           #ENDIF
  785.           #IF(%SortScrollNumeric)
  786.             #SET(%BrowseScrollParameters,%BrowseScrollParameters & 'ScrollSort:AllowNumeric')
  787.             #IF(%ScrollAlt)
  788.               #SET(%BrowseScrollParameters,%BrowseScrollParameters & '+')
  789.             #ENDIF
  790.           #ENDIF
  791.           #IF(%ScrollAlt)
  792.             #SET(%BrowseScrollParameters,%BrowseScrollParameters & 'ScrollSort:AllowAlt')
  793.           #ENDIF
  794.         #ENDIF
  795.       #ENDIF
  796.     #ENDIF
  797.   #ELSE
  798.     #SET(%BrowseScrollBehavior,'Fixed Thumb')
  799.   #ENDIF
  800. #ENDFOR
  801. #ADD(%BrowseAccessID,ITEMS(%BrowseAccessID)+1)
  802. #SET(%BrowseKey,%PrimaryKey)
  803. #SET(%BrowseTotalKeys,%BrowseAccessID)
  804. #SET(%BrowsePrefix,%InstancePrefix & ':Sort' & %BrowseAccessID)
  805. #SET(%BrowseCondition,%False)
  806. #SET(%BrowseRecordFilter,%RecordFilter)
  807. #FOR(%ResetFields)
  808.   #ADD(%BrowseResetField,%ResetField)
  809. #ENDFOR
  810. #IF(%BrowseKey)
  811.   #SET(%BrowseRangeField,%RangeField)
  812.   #SET(%BrowseRangeLimitType,%RangeLimitType)
  813.   #SET(%BrowseRangeLimit,%RangeLimit)
  814.   #SET(%BrowseRangeHigh,%RangeHigh)
  815.   #SET(%BrowseRangeLow,%RangeLow)
  816.   #SET(%BrowseRangeFile,%RangeFile)
  817.   #SET(%BrowseLocatorType,%LocatorType)
  818.   #IF(%BrowseLocatorType = 'Entry' OR %BrowseLocatorType = 'Incremental')
  819.     #IF(%OverrideDefaultLocator)
  820.   #SET(%BrowseLocatorControl,%OverrideLocator)
  821.     #ENDIF
  822.   #ENDIF
  823.   #IF(%VerticalScrollBarFound)
  824.     #SET(%BrowseScrollBehavior,%ScrollBehavior)
  825.     #IF(%BrowseScrollBehavior = 'Movable Thumb')
  826.       #SET(%BrowseScrollKeyDistribution,%ScrollKeyDistribution)
  827.       #IF(%BrowseScrollKeyDistribution = 'Custom')
  828.         #FOR(%CustomKeyDistribution)
  829.           #ADD(%BrowseKeyDistributionValue,%KeyDistributionValue)
  830.         #ENDFOR
  831.         #SET(%BrowseKeyDistributionCount,ITEMS(%BrowseKeyDistributionValue))
  832.       #ELSIF(%BrowseScrollKeyDistribution = 'Runtime')
  833.         #IF(%ScrollAlpha)
  834.           #SET(%BrowseScrollParameters,'ScrollSort:AllowAlpha')
  835.           #FIX(%File,%Primary)
  836.           #FIX(%Key,%BrowseKey)
  837.           #IF(NOT %KeyNoCase)
  838.             #SET(%BrowseScrollParameters,%BrowseScrollParameters & '+ScrollSort:CaseSensitive')
  839.           #ENDIF
  840.           #IF(%ScrollNumeric OR %ScrollAlt)
  841.             #SET(%BrowseScrollParameters,%BrowseScrollParameters & '+')
  842.           #ENDIF
  843.         #ENDIF
  844.         #IF(%ScrollNumeric)
  845.           #SET(%BrowseScrollParameters,%BrowseScrollParameters & 'ScrollSort:AllowNumeric')
  846.           #IF(%ScrollAlt)
  847.             #SET(%BrowseScrollParameters,%BrowseScrollParameters & '+')
  848.           #ENDIF
  849.         #ENDIF
  850.         #IF(%ScrollAlt)
  851.           #SET(%BrowseScrollParameters,%BrowseScrollParameters & 'ScrollSort:AllowAlt')
  852.         #ENDIF
  853.       #ENDIF
  854.     #ENDIF
  855.   #ENDIF
  856. #ELSE
  857.   #SET(%BrowseScrollBehavior,'Fixed Thumb')
  858. #ENDIF
  859. #FIX(%File,%Primary)
  860. #SET(%BrowseFiltersExist,%False)
  861. #FOR(%BrowseAccessID),WHERE(%BrowseKey)
  862.   #FIX(%Key,%BrowseKey)
  863.   #FOR(%KeyField)
  864.     #SET(%ValueConstruct,%InstancePrefix & ':' & %KeyField)
  865.     #FIX(%QueueField,%ValueConstruct)
  866.     #IF(%QueueField <> %ValueConstruct)
  867.     #ADD(%QueueField,%ValueConstruct)
  868.       #SET(%QueueFieldAssignment,%KeyField)
  869.     #ENDIF
  870.   #ENDFOR
  871.   #SET(%ValidRangeKey,%Null)
  872.   #IF(%BrowseRangeField)
  873.     #FOR(%KeyField)
  874.       #FIX(%Field,%KeyField)
  875.       #SET(%FieldIsString,%True)
  876.       #CASE(%FieldType)
  877.       #OF('STRING')
  878.       #OROF('CSTRING')
  879.       #OROF('PSTRING')
  880.       #OROF('GROUP')
  881.       #ELSE
  882.         #SET(%FieldIsString,%False)
  883.       #ENDCASE
  884.       #SET(%BrowseFreeElement,%KeyField)
  885.       #IF(%ValidRangeKey)
  886.         #BREAK
  887.       #ENDIF
  888.       #IF(UPPER(%KeyField)=UPPER(%BrowseRangeField))
  889.         #SET(%ValidRangeKey,%True)
  890.       #ELSE
  891.         #IF(%BrowseRangeLimitType <> 'File Relationship')
  892.           #ADD(%BrowseRangeLimitField,%KeyField)
  893.           #SET(%BrowseRangeLimitValue,%BrowsePrefix & ':Save:' & %KeyField)
  894.           #IF(%BrowseFilterStatement)
  895.             #SET(%BrowseFilterStatement,%BrowseFilterStatement & ' AND ')
  896.           #ENDIF
  897.           #IF(%KeyNoCase AND %FieldIsString)
  898.             #SET(%BrowseFilterStatement,%BrowseFilterStatement & 'UPPER(' & %KeyField & ') = UPPER(' & %BrowsePrefix & ':Save:' & %KeyField & ')')
  899.           #ELSE
  900.             #SET(%BrowseFilterStatement,%BrowseFilterStatement & %KeyField & ' = ' & %BrowsePrefix & ':Save:' & %KeyField)
  901.           #ENDIF
  902.           #ADD(%ListViewBoundField,%BrowsePrefix & ':Save:' & %KeyField)
  903.           #ADD(%BrowseResetField,%ListViewBoundField)
  904.         #ENDIF
  905.       #ENDIF
  906.     #ENDFOR
  907.     #IF(%ValidRangeKey=%Null)
  908.       #INSERT(%ErrorBrowseInvalidRangeField)
  909.     #ENDIF
  910.     #FIX(%Field,%BrowseRangeField)
  911.     #SET(%FieldIsString,%True)
  912.     #CASE(%FieldType)
  913.     #OF('STRING')
  914.     #OROF('CSTRING')
  915.     #OROF('PSTRING')
  916.     #OROF('GROUP')
  917.     #ELSE
  918.       #SET(%FieldIsString,%False)
  919.     #ENDCASE
  920.     #CASE(%BrowseRangeLimitType)
  921.     #OF('Single Value')
  922.       #IF(%BrowseRangeLimit)
  923.         #ADD(%BrowseRangeLimitField,%BrowseRangeField)
  924.         #SET(%BrowseRangeLimitValue,%BrowseRangeLimit)
  925.         #IF(%BrowseFilterStatement)
  926.           #SET(%BrowseFilterStatement,%BrowseFilterStatement & ' AND ')
  927.         #ENDIF
  928.         #IF(%KeyNoCase AND %FieldIsString)
  929.           #SET(%BrowseFilterStatement,%BrowseFilterStatement & 'UPPER(' & %BrowseRangeField & ') = UPPER(' & %BrowseRangeLimit & ')')
  930.         #ELSE
  931.           #SET(%BrowseFilterStatement,%BrowseFilterStatement & %BrowseRangeField & ' = ' & %BrowseRangeLimit)
  932.         #ENDIF
  933.         #ADD(%ListViewBoundField,%BrowseRangeLimit)
  934.         #ADD(%BrowseResetField,%ListViewBoundField)
  935.       #ELSE
  936.         #INSERT(%ErrorBrowseLimitFieldMissing)
  937.       #ENDIF
  938.     #OF('Range of Values')
  939.       #IF(%BrowseRangeLow)
  940.         #ADD(%BrowseRangeLimitField,%BrowseRangeField)
  941.         #SET(%BrowseRangeLimitValue,%BrowseRangeLow)
  942.         #IF(%BrowseFilterStatement)
  943.           #SET(%BrowseFilterStatement,%BrowseFilterStatement & ' AND ')
  944.         #ENDIF
  945.         #IF(%KeyNoCase AND %FieldIsString)
  946.           #SET(%BrowseFilterStatement,%BrowseFilterStatement & 'UPPER(' & %BrowseRangeField & ') >= UPPER(' & %BrowseRangeLow & ')')
  947.         #ELSE
  948.           #SET(%BrowseFilterStatement,%BrowseFilterStatement & %BrowseRangeField & ' >= ' & %BrowseRangeLow)
  949.         #ENDIF
  950.         #ADD(%ListViewBoundField,%BrowseRangeField)
  951.         #ADD(%ListViewBoundField,%BrowseRangeLow)
  952.         #ADD(%BrowseResetField,%ListViewBoundField)
  953.       #ELSE
  954.         #INSERT(%ErrorBrowseLowLimitMissing)
  955.       #ENDIF
  956.       #IF(%BrowseRangeHigh)
  957.         #IF(%BrowseFilterStatement)
  958.           #SET(%BrowseFilterStatement,%BrowseFilterStatement & ' AND ')
  959.         #ENDIF
  960.         #IF(%KeyNoCase AND %FieldIsString)
  961.           #SET(%BrowseFilterStatement,%BrowseFilterStatement & 'UPPER(' & %BrowseRangeField & ') <<= UPPER(' & %BrowseRangeHigh & ')')
  962.         #ELSE
  963.           #SET(%BrowseFilterStatement,%BrowseFilterStatement & %BrowseRangeField & ' <<= ' & %BrowseRangeHigh)
  964.         #ENDIF
  965.         #ADD(%ListViewBoundField,%BrowseRangeField)
  966.         #ADD(%ListViewBoundField,%BrowseRangeHigh)
  967.         #ADD(%BrowseResetField,%ListViewBoundField)
  968.       #ELSE
  969.         #INSERT(%ErrorBrowseHighLimitMissing)
  970.       #ENDIF
  971.     #OF('File Relationship')
  972.       #FIX(%File,%Primary)
  973.       #FIX(%Relation,%BrowseRangeFile)
  974.       #IF(%Relation)
  975.         #FOR(%FileKeyField),WHERE(%FileKeyField AND %FileKeyFieldLink)
  976.           #FIX(%Field,%FileKeyField)
  977.           #SET(%FieldIsString,%True)
  978.           #CASE(%FieldType)
  979.           #OF('STRING')
  980.           #OROF('CSTRING')
  981.           #OROF('PSTRING')
  982.           #OROF('GROUP')
  983.           #ELSE
  984.             #SET(%FieldIsString,%False)
  985.           #ENDCASE
  986.           #ADD(%BrowseRangeLimitField,%FileKeyField)
  987.           #SET(%BrowseRangeLimitValue,%FileKeyFieldLink)
  988.           #IF(%BrowseFilterStatement)
  989.             #SET(%BrowseFilterStatement,%BrowseFilterStatement & ' AND ')
  990.           #ENDIF
  991.           #IF(%KeyNoCase AND %FieldIsString)
  992.             #SET(%BrowseFilterStatement,%BrowseFilterStatement & 'UPPER(' & %FileKeyField & ') = UPPER(' & %BrowsePrefix & ':Reset:' & %FileKeyFieldLink & ')')
  993.           #ELSE
  994.             #SET(%BrowseFilterStatement,%BrowseFilterStatement & %FileKeyField & ' = ' & %BrowsePrefix & ':Reset:' & %FileKeyFieldLink)
  995.           #ENDIF
  996.           #ADD(%ListViewBoundField,%FileKeyField)
  997.           #ADD(%ListViewBoundField,%FileKeyFieldLink)
  998.           #ADD(%ListViewBoundField,%BrowsePrefix & ':Reset:' & %FileKeyFieldLink)
  999.           #ADD(%BrowseResetField,%FileKeyFieldLink)
  1000.         #ENDFOR
  1001.       #ELSE
  1002.         #INSERT(%ErrorBrowseRelationshipMissing)
  1003.       #ENDIF
  1004.     #ELSE
  1005.       #ADD(%BrowseRangeLimitField,%BrowseRangeField)
  1006.       #SET(%BrowseRangeLimitValue,%BrowsePrefix & ':Save:' & %BrowseRangeField)
  1007.       #IF(%BrowseFilterStatement)
  1008.         #SET(%BrowseFilterStatement,%BrowseFilterStatement & ' AND ')
  1009.       #ENDIF
  1010.       #IF(%KeyNoCase AND %FieldIsString)
  1011.         #SET(%BrowseFilterStatement,%BrowseFilterStatement & 'UPPER(' & %BrowseRangeField & ') = UPPER(' & %BrowsePrefix & ':Save:' & %BrowseRangeField & ')')
  1012.       #ELSE
  1013.         #SET(%BrowseFilterStatement,%BrowseFilterStatement & %BrowseRangeField & ' = ' & %BrowsePrefix & ':Save:' & %BrowseRangeField)
  1014.       #ENDIF
  1015.       #ADD(%ListViewBoundField,%BrowseRangeField)
  1016.       #ADD(%ListViewBoundField,%BrowsePrefix & ':Save:' & %BrowseRangeField)
  1017.       #ADD(%BrowseResetField,%ListViewBoundField)
  1018.     #ENDCASE
  1019.   #ENDIF
  1020.   #FIX(%Key,%BrowseKey)
  1021.   #SET(%BrowseLocatorName,%Null)
  1022.   #IF(%BrowseLocatorType <> 'None')
  1023.     #IF(%BrowseRangeField)
  1024.       #FOR(%KeyField)
  1025.         #IF(%BrowseLocatorName)
  1026.           #IF(%BrowseRangeLimitType <> 'Range of Values')
  1027.             #SET(%BrowseLocatorName,%KeyField)
  1028.           #ENDIF
  1029.           #BREAK
  1030.         #ELSE
  1031.           #IF(UPPER(%KeyField)=UPPER(%BrowseRangeField))
  1032.             #SET(%BrowseLocatorName,%KeyField)
  1033.           #ENDIF
  1034.         #ENDIF
  1035.       #ENDFOR
  1036.     #ELSE
  1037.       #FOR(%KeyField)
  1038.         #SET(%BrowseLocatorName,%KeyField)
  1039.         #BREAK
  1040.       #ENDFOR
  1041.     #ENDIF
  1042.     #IF(%BrowseLocatorType = 'Entry' OR %BrowseLocatorType = 'Incremental')
  1043.       #IF(%BrowseLocatorControl)
  1044.         #FIX(%Control,%BrowseLocatorControl)
  1045.         #IF(NOT %Control)
  1046.           #SET(%BrowseLocatorControl,%Null)
  1047.         #ENDIF
  1048.       #ELSE
  1049.         #FOR(%Control)
  1050.           #IF(UPPER(%ControlUse)=UPPER(%BrowseLocatorName))
  1051.             #SET(%BrowseLocatorControl,%Control)
  1052.             #BREAK
  1053.           #ENDIF
  1054.         #ENDFOR
  1055.       #ENDIF
  1056.     #ENDIF
  1057.     #IF(%BrowseLocatorName=%Null)
  1058.       #INSERT(%ErrorBrowseLocatorNoFreeKey)
  1059.       #SET(%BrowseLocatorType,'None')
  1060.     #ELSIF(%BrowseLocatorControl = %Null AND %BrowseLocatorType = 'Entry')
  1061.       #INSERT(%ErrorBrowseLocatorNoEntryControl)
  1062.       #SET(%BrowseLocatorType,'Step')
  1063.     #ENDIF
  1064.     #IF(%BrowseLocatorName)
  1065.       #SET(%BrowseFreeElement,%BrowseLocatorName)
  1066.     #ENDIF
  1067.   #ENDIF
  1068.   #IF(%BrowseFreeElement=%Null)
  1069.     #FOR(%KeyField)
  1070.       #SET(%BrowseFreeElement,%KeyField)
  1071.       #BREAK
  1072.     #ENDFOR
  1073.   #ENDIF
  1074.   #IF(%BrowseRecordFilter)
  1075.     #IF(%BrowseFilterStatement)
  1076.       #SET(%BrowseFilterStatement,%BrowseFilterStatement & ' AND ')
  1077.     #ENDIF
  1078.     #SET(%BrowseFilterStatement,%BrowseFilterStatement & '(' & %BrowseRecordFilter & ')')
  1079.   #ENDIF
  1080.   #IF(%BrowseFilterStatement)
  1081.     #SET(%BrowseFiltersExist,%True)
  1082.   #ENDIF
  1083. #ENDFOR
  1084. #FOR(%BrowseAccessID),WHERE(NOT %BrowseKey)
  1085.   #IF(%BrowseRecordFilter)
  1086.     #SET(%BrowseFilterStatement,%BrowseFilterStatement & '(' & %BrowseRecordFilter & ')')
  1087.   #ENDIF
  1088.   #IF(%BrowseFilterStatement)
  1089.     #SET(%BrowseFiltersExist,%True)
  1090.   #ENDIF
  1091. #ENDFOR
  1092. #EMBED(%BottomofSetupBrowseBehavior,'INTERNAL Bottom of SetupBrowseBehavior GROUP'),HIDE
  1093. #!----------------------------------------------------------------------
  1094. #GROUP(%BrowseRoutineInitializeBrowse)
  1095. !----------------------------------------------------------------------
  1096. %InstancePrefix:InitializeBrowse ROUTINE
  1097.   #IF(%EnableQuickScan)
  1098.   #EMBED(%BeforeTurnQuickScanOn,'Before Turning QuickScan On'),WHERE(%EnableQuickScan)
  1099.   IF SEND(%Primary,'QUICKSCAN=on').
  1100.   #EMBED(%AfterTurnQuickScanOn,'After Turning QuickScan On'),WHERE(%EnableQuickScan)
  1101.   #ENDIF
  1102.   #EMBED(%StartInitializeBrowseRoutine,'Start of Initialize Browse ROUTINE'),HIDE
  1103.   #SUSPEND
  1104.   #?SETCURSOR(Cursor:Wait)
  1105.   #?DO %InstancePrefix:Reset
  1106.     #FOR(%BrowseTotals)
  1107.       #CASE(%BrowseTotalType)
  1108.       #OF('Count')
  1109.   %InstancePrefix:%BrowseTotalTarget:Cnt:Value = 0
  1110.       #OF('Sum')
  1111.   %InstancePrefix:%BrowseTotalTarget:Sum:Value = 0
  1112.       #OF('Average')
  1113.   %InstancePrefix:%BrowseTotalTarget:Cnt:Value = 0
  1114.   %InstancePrefix:%BrowseTotalTarget:Sum:Value = 0
  1115.       #ENDCASE
  1116.     #ENDFOR
  1117.   #EMBED(%BeforeTotalLoop,'Before Browse Total Loop'),WHERE(ITEMS(%BrowseTotals)),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  1118.   #?LOOP
  1119.     #FIX(%File,%Primary)
  1120.     #?NEXT(%ListView)
  1121.     #?IF ERRORCODE()
  1122.       #?IF ERRORCODE() = BadRecErr
  1123.         #?DO %InstancePrefix:RestoreResetValues
  1124.         #?BREAK
  1125.       #?ELSE
  1126.         #?StandardWarning(Warn:RecordFetchError,'%File')
  1127.         #?POST(Event:CloseWindow)
  1128.         #?EXIT
  1129.       #?END
  1130.     #?END
  1131.     #IF(%UseValidateRoutine)
  1132.     #?DO %InstancePrefix:ValidateRecord
  1133.     #?EXECUTE(%InstancePrefix:RecordStatus)
  1134.       #?BREAK
  1135.       #?CYCLE
  1136.     #?END
  1137.     #ENDIF
  1138.     #?DO %InstancePrefix:FillQueue
  1139.     #FOR(%BrowseTotals)
  1140.       #IF(%BrowseTotalCondition)
  1141.     IF (%BrowseTotalCondition)
  1142.         #CASE(%BrowseTotalType)
  1143.         #OF('Count')
  1144.       %InstancePrefix:%BrowseTotalTarget:Cnt:Value += 1
  1145.         #OF('Sum')
  1146.       %InstancePrefix:%BrowseTotalTarget:Sum:Value += %BrowseTotalField
  1147.         #OF('Average')
  1148.       %InstancePrefix:%BrowseTotalTarget:Cnt:Value += 1
  1149.       %InstancePrefix:%BrowseTotalTarget:Sum:Value += %BrowseTotalField
  1150.         #ENDCASE
  1151.     END
  1152.       #ELSE
  1153.         #CASE(%BrowseTotalType)
  1154.         #OF('Count')
  1155.     %InstancePrefix:%BrowseTotalTarget:Cnt:Value += 1
  1156.         #OF('Sum')
  1157.     %InstancePrefix:%BrowseTotalTarget:Sum:Value += %BrowseTotalField
  1158.         #OF('Average')
  1159.     %InstancePrefix:%BrowseTotalTarget:Cnt:Value += 1
  1160.     %InstancePrefix:%BrowseTotalTarget:Sum:Value += %BrowseTotalField
  1161.         #ENDCASE
  1162.       #ENDIF
  1163.     #ENDFOR
  1164.     #EMBED(%TotalLoop,'Browse Total Loop'),WHERE(ITEMS(%BrowseTotals)),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  1165.   #?END
  1166.   #EMBED(%AfterTotalLoop,'After Browse Total Loop'),WHERE(ITEMS(%BrowseTotals)),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  1167.     #FOR(%BrowseTotals)
  1168.       #CASE(%BrowseTotalType)
  1169.       #OF('Count')
  1170.   %BrowseTotalTarget = %InstancePrefix:%BrowseTotalTarget:Cnt:Value
  1171.       #OF('Sum')
  1172.   %BrowseTotalTarget = %InstancePrefix:%BrowseTotalTarget:Sum:Value
  1173.       #OF('Average')
  1174.   %BrowseTotalTarget = %InstancePrefix:%BrowseTotalTarget:Sum:Value/%InstancePrefix:%BrowseTotalTarget:Cnt:Value
  1175.       #ENDCASE
  1176.     #ENDFOR
  1177.   #?SETCURSOR()
  1178.   #RESUME
  1179.   #IF(%VerticalScrollBarFound)
  1180.     #SUSPEND
  1181.   #?DO %InstancePrefix:Reset
  1182.   #IF(%UseValidateRoutine)
  1183.   #?LOOP
  1184.     #?PREVIOUS(%ListView)
  1185.     #?IF ERRORCODE()
  1186.       #?IF ERRORCODE() = BadRecErr
  1187.         #?DO %InstancePrefix:RestoreResetValues
  1188.         #?BREAK
  1189.       #?ELSE
  1190.         #?StandardWarning(Warn:RecordFetchError,'%File')
  1191.         #?POST(Event:CloseWindow)
  1192.         #?EXIT
  1193.       #?END
  1194.     #?END
  1195.     #?DO %InstancePrefix:ValidateRecord
  1196.     #?EXECUTE(%InstancePrefix:RecordStatus)
  1197.       #?BREAK
  1198.       #?CYCLE
  1199.     #?END
  1200.     #?BREAK
  1201.   #?END
  1202.   #ELSE
  1203.   #?PREVIOUS(%ListView)
  1204.   #?IF ERRORCODE()
  1205.     #?IF ERRORCODE() = BadRecErr
  1206.       #?DO %InstancePrefix:RestoreResetValues
  1207.     #?ELSE
  1208.       #?StandardWarning(Warn:RecordFetchError,'%File')
  1209.       #?POST(Event:CloseWindow)
  1210.     #?END
  1211.     #?EXIT
  1212.   #?END
  1213.   #ENDIF
  1214.   #?CASE %InstancePrefix:SortOrder
  1215.       #FOR(%BrowseAccessID),WHERE(%BrowseFreeElement AND %BrowseScrollKeyDistribution = 'Runtime')
  1216.         #FIX(%File,%Primary)
  1217.         #FIX(%Key,%BrowseKey)
  1218.         #FIX(%KeyField,%BrowseFreeElement)
  1219.   OF %BrowseAccessID
  1220.     %BrowsePrefix:HighValue = %BrowseFreeElement
  1221.       #ENDFOR
  1222.   #?END
  1223.   #?DO %InstancePrefix:Reset
  1224.   #IF(%UseValidateRoutine)
  1225.   #?LOOP
  1226.     #?NEXT(%ListView)
  1227.     #?IF ERRORCODE()
  1228.       #?IF ERRORCODE() = BadRecErr
  1229.         #?DO %InstancePrefix:RestoreResetValues
  1230.         #?BREAK
  1231.       #?ELSE
  1232.         #?StandardWarning(Warn:RecordFetchError,'%File')
  1233.         #?POST(Event:CloseWindow)
  1234.         #?EXIT
  1235.       #?END
  1236.     #?END
  1237.     #?DO %InstancePrefix:ValidateRecord
  1238.     #?EXECUTE(%InstancePrefix:RecordStatus)
  1239.       #?BREAK
  1240.       #?CYCLE
  1241.     #?END
  1242.     #?BREAK
  1243.   #?END
  1244.   #ELSE
  1245.   #?NEXT(%ListView)
  1246.   #?IF ERRORCODE()
  1247.     #?IF ERRORCODE() = BadRecErr
  1248.       #?DO %InstancePrefix:RestoreResetValues
  1249.     #?ELSE
  1250.       #?StandardWarning(Warn:RecordFetchError,'%File')
  1251.       #?POST(Event:CloseWindow)
  1252.     #?END
  1253.     #?EXIT
  1254.   #?END
  1255.   #ENDIF
  1256.   #?CASE %InstancePrefix:SortOrder
  1257.       #FOR(%BrowseAccessID),WHERE(%BrowseFreeElement AND %BrowseScrollKeyDistribution = 'Runtime')
  1258.         #FIX(%File,%Primary)
  1259.         #FIX(%Key,%BrowseKey)
  1260.         #FIX(%KeyField,%BrowseFreeElement)
  1261.         #FIX(%Field,%KeyField)
  1262.   OF %BrowseAccessID
  1263.     %BrowsePrefix:LowValue = %BrowseFreeElement
  1264.         #CASE(%FieldType)
  1265.         #OF('STRING')
  1266.         #OROF('PSTRING')
  1267.         #OROF('CSTRING')
  1268.         #OROF('GROUP')
  1269.     SetupStringStops(%BrowsePrefix:LowValue,%BrowsePrefix:HighValue,SIZE(%BrowsePrefix:LowValue),%BrowseScrollParameters)
  1270.     LOOP %InstancePrefix:ScrollRecordCount = 1 TO 100
  1271.       %BrowsePrefix:KeyDistribution[%InstancePrefix:ScrollRecordCount] = NextStringStop()
  1272.     END
  1273.         #ELSE                    
  1274.     SetupRealStops(%BrowsePrefix:LowValue,%BrowsePrefix:HighValue)
  1275.     LOOP %InstancePrefix:ScrollRecordCount = 1 TO 100
  1276.       %BrowsePrefix:KeyDistribution[%InstancePrefix:ScrollRecordCount] = NextRealStop()
  1277.     END
  1278.         #ENDCASE
  1279.       #ENDFOR
  1280.   #?END
  1281.     #RESUME
  1282.   #ENDIF
  1283.   #IF(%EnableQuickScan)
  1284.   #EMBED(%BeforeTurnQuickScanOff,'Before Turning QuickScan Off'),WHERE(%EnableQuickScan)
  1285.   IF SEND(%Primary,'QUICKSCAN=off').
  1286.   #EMBED(%AfterTurnQuickScanOff,'After Turning QuickScan Off'),WHERE(%EnableQuickScan)
  1287.   #ENDIF
  1288.   #EMBED(%EndInitializeBrowseRoutine,'End of Initialize Browse ROUTINE'),HIDE
  1289. #!----------------------------------------------------------------------
  1290. #GROUP(%BrowseRoutineFillBuffer)
  1291. !----------------------------------------------------------------------
  1292. %InstancePrefix:FillBuffer ROUTINE
  1293.   #EMBED(%StartFillBufferRoutine,'Start of Fill Buffer ROUTINE'),HIDE
  1294.   #FOR(%QueueField)                           #! FOR each field in list
  1295.   %QueueFieldAssignment = %QueueField
  1296.   #ENDFOR
  1297.   #EMBED(%EndFillBufferRoutine,'Start of Fill Buffer ROUTINE'),HIDE
  1298. #!----------------------------------------------------------------------
  1299. #GROUP(%BrowseRoutineSelectSort)
  1300. !----------------------------------------------------------------------
  1301. %InstancePrefix:SelectSort ROUTINE
  1302.   %InstancePrefix:LastSortOrder = %InstancePrefix:SortOrder
  1303.   %InstancePrefix:Changed = False
  1304.   #IF(ITEMS(%BrowseAccessID) > 1)
  1305.     #SET(%ValueConstruct,%False)
  1306.     #FOR(%BrowseAccessID)
  1307.       #IF(%BrowseAccessID = 1)
  1308.   IF %BrowseCondition
  1309.       #ELSIF(%BrowseAccessID = ITEMS(%BrowseAccessID))
  1310.   ELSE
  1311.       #ELSE
  1312.   ELSIF %BrowseCondition
  1313.       #ENDIF
  1314.     %InstancePrefix:SortOrder = %BrowseAccessID
  1315.     #ENDFOR
  1316.   END
  1317.   #ELSE
  1318.   IF %InstancePrefix:SortOrder = 0
  1319.     %InstancePrefix:SortOrder = 1
  1320.   END
  1321.   #ENDIF
  1322.   #SUSPEND
  1323.   #?IF %InstancePrefix:SortOrder = %InstancePrefix:LastSortOrder
  1324.     #?CASE %InstancePrefix:SortOrder
  1325.     #FOR(%BrowseAccessID)
  1326.       #SUSPEND
  1327.     #?OF %BrowseAccessID
  1328.         #FOR(%BrowseResetField)
  1329.           #IF(ITEMS(%BrowseResetField) = 1)
  1330.       IF %BrowsePrefix:Reset:%BrowseResetField <> %BrowseResetField
  1331.           #ELSIF(INSTANCE(%BrowseResetField)=1)
  1332.       IF %BrowsePrefix:Reset:%BrowseResetField <> %BrowseResetField |
  1333.           #ELSIF(INSTANCE(%BrowseResetField)=ITEMS(%BrowseResetField))
  1334.       OR %BrowsePrefix:Reset:%BrowseResetField <> %BrowseResetField
  1335.           #ELSE
  1336.       OR %BrowsePrefix:Reset:%BrowseResetField <> %BrowseResetField |
  1337.           #ENDIF
  1338.         #ENDFOR
  1339.         #?%InstancePrefix:Changed = True
  1340.       #?END
  1341.       #RESUME
  1342.     #ENDFOR
  1343.     #?END
  1344.   #?ELSE
  1345.     #SUSPEND
  1346.     #?CASE %InstancePrefix:SortOrder
  1347.       #FOR(%BrowseAccessID),WHERE(%BrowseKey)
  1348.         #SUSPEND
  1349.     #?OF %BrowseAccessID
  1350.           #IF(%BrowseRangeField)
  1351.             #IF(%BrowseRangeLimitType = 'File Relationship')
  1352.               #RESUME
  1353.               #CYCLE
  1354.             #ENDIF
  1355.             #FIX(%Key,%BrowseKey)
  1356.             #FOR(%KeyField)
  1357.               #IF(UPPER(%KeyField)=UPPER(%BrowseRangeField))
  1358.                 #IF(%BrowseRangeLimitType = 'Current Value')
  1359.       %BrowsePrefix:Save:%KeyField = %KeyField
  1360.                 #ENDIF
  1361.                 #BREAK
  1362.               #ELSE
  1363.       %BrowsePrefix:Save:%KeyField = %KeyField
  1364.               #ENDIF
  1365.             #ENDFOR
  1366.           #ENDIF
  1367.           #IF(%BrowseLocatorType = 'Incremental')
  1368.       %BrowsePrefix:LocatorValue = ''
  1369.       %BrowsePrefix:LocatorLength = 0
  1370.       %BrowseLocatorName = %BrowsePrefix:LocatorValue
  1371.           #ENDIF
  1372.         #RESUME
  1373.       #ENDFOR
  1374.     #?END
  1375.     #RESUME
  1376.   #?END
  1377.   #RESUME
  1378.   IF %InstancePrefix:SortOrder <> %InstancePrefix:LastSortOrder OR %InstancePrefix:Changed OR ForceRefresh
  1379.   #SUSPEND
  1380.     #?CASE %InstancePrefix:SortOrder
  1381.     #FOR(%BrowseAccessID),WHERE(ITEMS(%BrowseResetField))
  1382.     OF %BrowseAccessID
  1383.       #FOR(%BrowseResetField)
  1384.       %BrowsePrefix:Reset:%BrowseResetField = %BrowseResetField
  1385.       #ENDFOR
  1386.     #ENDFOR
  1387.     #?END
  1388.   #RESUME
  1389.     DO %InstancePrefix:GetRecord
  1390.     DO %InstancePrefix:Reset
  1391.     IF %InstancePrefix:LastSortOrder = 0
  1392.       IF LocalRequest = SelectRecord
  1393.         %InstancePrefix:LocateMode = LocateOnValue
  1394.         DO %InstancePrefix:LocateRecord
  1395.       ELSE
  1396.         %InstancePrefix:RefreshMode = RefreshOnTop
  1397.         DO %InstancePrefix:RefreshPage
  1398.         DO %InstancePrefix:PostNewSelection
  1399.       END
  1400.     ELSE
  1401.       IF %InstancePrefix:Changed
  1402.         %InstancePrefix:RefreshMode = RefreshOnTop
  1403.         DO %InstancePrefix:RefreshPage
  1404.         DO %InstancePrefix:PostNewSelection
  1405.       ELSE
  1406.         %InstancePrefix:LocateMode = LocateOnValue
  1407.         DO %InstancePrefix:LocateRecord
  1408.       END
  1409.     END
  1410.     IF %InstancePrefix:RecordCount
  1411.       GET(%ListQueue,%InstancePrefix:CurrentChoice)
  1412.       DO %InstancePrefix:FillBuffer
  1413.     END
  1414.     DO %InstancePrefix:InitializeBrowse
  1415.   ELSE
  1416.     IF %InstancePrefix:RecordCount
  1417.       GET(%ListQueue,%InstancePrefix:CurrentChoice)
  1418.       DO %InstancePrefix:FillBuffer
  1419.     END
  1420.   END
  1421. #!---------------------------------------------------------------------
  1422. #GROUP(%BrowseRoutineReset)
  1423. %InstancePrefix:Reset ROUTINE
  1424.   #EMBED(%CodeTypeElse,'BrowseReset ROUTINE, before setting range limit values'),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  1425.   CLOSE(%ListView)
  1426.   CASE %InstancePrefix:SortOrder
  1427.     #FOR(%BrowseAccessID)
  1428.   OF %BrowseAccessID
  1429.       #IF(%BrowseKey)
  1430.         #FOR(%BrowseRangeLimitField)
  1431.     %BrowseRangeLimitField = %BrowseRangeLimitValue
  1432.         #ENDFOR
  1433.     SET(%BrowseKey)
  1434.       #ELSE
  1435.     SET(%Primary)
  1436.       #ENDIF
  1437.       #IF(%BrowseFiltersExist)
  1438.     %ListView{Prop:Filter} = '%'BrowseFilterStatement'
  1439.       #ELSE
  1440.     %ListView{Prop:Filter} = ''
  1441.       #ENDIF
  1442.     #ENDFOR
  1443.   END
  1444.   OPEN(%ListView)
  1445. !----------------------------------------------------------------------
  1446. #!---------------------------------------------------------------------
  1447. #GROUP(%BrowseRoutineFillQueue)
  1448. !----------------------------------------------------------------------
  1449. %InstancePrefix:FillQueue ROUTINE
  1450.   #EMBED(%FormatBrowse,'Format an element of the browse queue'),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  1451.   #INSERT(%StandardFormula,'Format Browse')
  1452.   #FIX(%Control,%ListControl)
  1453.   #FOR(%QueueField)
  1454.   %QueueField = %QueueFieldAssignment
  1455.     #IF(%QueueFieldHasColor)
  1456.       #FIX(%ControlField,%QueueFieldAssignment)
  1457.       #IF(ITEMS(%ConditionalColors))
  1458.         #FOR(%ConditionalColors)
  1459.           #IF(INSTANCE(%ConditionalColors) = 1)
  1460.   IF (%ColorCondition)
  1461.           #ELSE
  1462.   ELSIF (%ColorCondition)
  1463.           #ENDIF
  1464.     %QueueField:NormalFG = %ConditionalControlFieldForegroundNormal
  1465.     %QueueField:NormalBG = %ConditionalControlFieldBackgroundNormal
  1466.     %QueueField:SelectedFG = %ConditionalControlFieldForegroundSelected
  1467.     %QueueField:SelectedBG = %ConditionalControlFieldBackgroundSelected
  1468.         #ENDFOR
  1469.   ELSE
  1470.     %QueueField:NormalFG = %ControlFieldForegroundNormal
  1471.     %QueueField:NormalBG = %ControlFieldBackgroundNormal
  1472.     %QueueField:SelectedFG = %ControlFieldForegroundSelected
  1473.     %QueueField:SelectedBG = %ControlFieldBackgroundSelected
  1474.   END
  1475.       #ELSE
  1476.     %QueueField:NormalFG = %ControlFieldForegroundNormal
  1477.     %QueueField:NormalBG = %ControlFieldBackgroundNormal
  1478.     %QueueField:SelectedFG = %ControlFieldForegroundSelected
  1479.     %QueueField:SelectedBG = %ControlFieldBackgroundSelected
  1480.       #ENDIF
  1481.     #ENDIF
  1482.     #IF(%QueueFieldHasIcon)
  1483.       #FIX(%ControlField,%QueueFieldAssignment)
  1484.       #IF(ITEMS(%ConditionalIcons))
  1485.         #FOR(%ConditionalIcons)
  1486.           #IF(INSTANCE(%ConditionalIcons) = 1)
  1487.   IF (%IconCondition)
  1488.           #ELSE
  1489.   ELSIF (%IconCondition)
  1490.           #ENDIF
  1491.           #FIX(%IconList,%ConditionalControlFieldIcon)
  1492.           #IF(%IconList)
  1493.             #CASE(%IconListType)
  1494.             #OF('Variable')
  1495.     %QueueField:Icon = %IconList
  1496.             #ELSE
  1497.               #SET(%ValueConstruct,INSTANCE(%IconList))
  1498.     %QueueField:Icon = %ValueConstruct
  1499.             #ENDCASE
  1500.           #ELSE
  1501.     %QueueField:Icon = 0
  1502.           #ENDIF
  1503.         #ENDFOR
  1504.   ELSE
  1505.         #FIX(%IconList,%ControlFieldIcon)
  1506.         #IF(%IconList)
  1507.           #CASE(%IconListType)
  1508.           #OF('Variable')
  1509.     %QueueField:Icon = %IconList
  1510.           #ELSE
  1511.             #SET(%ValueConstruct,INSTANCE(%IconList))
  1512.     %QueueField:Icon = %ValueConstruct
  1513.           #ENDCASE
  1514.         #ELSE
  1515.     %QueueField:Icon = 0
  1516.         #ENDIF
  1517.   END
  1518.       #ELSE
  1519.         #FIX(%IconList,%ControlFieldIcon)
  1520.         #IF(%IconList)
  1521.           #CASE(%IconListType)
  1522.           #OF('Variable')
  1523.     %QueueField:Icon = %IconList
  1524.           #ELSE
  1525.             #SET(%ValueConstruct,INSTANCE(%IconList))
  1526.     %QueueField:Icon = %ValueConstruct
  1527.           #ENDCASE
  1528.         #ELSE
  1529.     %QueueField:Icon = 0
  1530.         #ENDIF
  1531.       #ENDIF
  1532.     #ENDIF
  1533.   #ENDFOR
  1534.   %InstancePrefix:Position = POSITION(%ListView)
  1535.   #EMBED(%EndOfFormatBrowse,'End of Format an element of the browse queue'),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  1536. #!---------------------------------------------------------------------
  1537. #GROUP(%BrowseRoutinePostNewSelection)
  1538. !----------------------------------------------------------------------
  1539. %InstancePrefix:PostNewSelection ROUTINE
  1540.   IF NOT %InstancePrefix:NewSelectPosted
  1541.     %InstancePrefix:NewSelectPosted = True
  1542.     POST(Event:NewSelection,%ListControl)
  1543.   END
  1544. #!---------------------------------------------------------------------
  1545. #GROUP(%BrowseRoutineNewSelection)
  1546. !----------------------------------------------------------------------
  1547. %InstancePrefix:NewSelection ROUTINE
  1548.   %InstancePrefix:NewSelectPosted = False
  1549.   IF KEYCODE() = MouseRight
  1550.     %InstancePrefix:PopupText = ''
  1551.     IF %InstancePrefix:RecordCount
  1552.       #EMBED(%BrowseBoxPopupRecords,'INTERNAL Browse Box Popup with Records'),HIDE
  1553.     ELSE
  1554.       #EMBED(%BrowseBoxPopupNoRecords,'INTERNAL Browse Box Popup with No Records'),HIDE
  1555.     END
  1556.     EXECUTE(POPUP(%InstancePrefix:PopupText))
  1557.       #EMBED(%BrowseBoxEditPopupHandling,'INTERNAL Browse Box Popup Handling'),HIDE
  1558.       #EMBED(%BrowseBoxSelectPopupHandling,'INTERNAL Browse Box Popup Handling'),HIDE
  1559.     END
  1560.   ELSIF %InstancePrefix:RecordCount
  1561.     %InstancePrefix:CurrentChoice = CHOICE(%ListControl)
  1562.     GET(%ListQueue,%InstancePrefix:CurrentChoice)
  1563.     DO %InstancePrefix:FillBuffer
  1564.   #IF(%VerticalScrollBarFound)
  1565.     IF %InstancePrefix:RecordCount = %ListControl{Prop:Items}
  1566.       IF %ListControl{Prop:VScroll} = False
  1567.         %ListControl{Prop:VScroll} = True
  1568.       END
  1569.     #SUSPEND
  1570.       #?CASE %InstancePrefix:SortOrder
  1571.       #FOR(%BrowseAccessID)
  1572.       #?OF %BrowseAccessID
  1573.         #IF(%BrowseScrollBehavior = 'Movable Thumb')
  1574.           #FIX(%File,%Primary)
  1575.           #FIX(%Key,%BrowseKey)
  1576.           #IF(%BrowseScrollKeyDistribution)
  1577.             #FIX(%Field,%BrowseFreeElement)
  1578.             #FIX(%KeyField,%BrowseFreeElement)
  1579.             #IF(%BrowseScrollKeyDistribution = 'Custom')
  1580.               #IF(%KeyFieldSequence = 'ASCENDING')
  1581.         LOOP %InstancePrefix:CurrentScroll = 1 TO %BrowseKeyDistributionCount
  1582.               #ELSE
  1583.         LOOP %InstancePrefix:CurrentScroll = %BrowseKeyDistributionCount TO 1 BY -1
  1584.               #ENDIF
  1585.             #ELSE
  1586.               #IF(%KeyFieldSequence = 'ASCENDING')
  1587.         LOOP %InstancePrefix:CurrentScroll = 1 TO 100
  1588.               #ELSE
  1589.         LOOP %InstancePrefix:CurrentScroll = 100 TO 1 BY -1
  1590.               #ENDIF
  1591.             #ENDIF
  1592.             #FIX(%Field,%BrowseFreeElement)
  1593.             #FIX(%KeyField,%BrowseFreeElement)
  1594.             #IF(%BrowseScrollKeyDistribution = 'Alpha')
  1595.               #IF(%KeyNoCase)
  1596.           IF Sort:Alpha:Array[%InstancePrefix:CurrentScroll] => UPPER(%BrowseFreeElement)
  1597.               #ELSE
  1598.           IF Sort:Alpha:Array[%InstancePrefix:CurrentScroll] => %BrowseFreeElement
  1599.               #ENDIF
  1600.             #ELSIF(%BrowseScrollKeyDistribution='Last Names')
  1601.               #IF(%KeyNoCase)
  1602.           IF Sort:Name:Array[%InstancePrefix:CurrentScroll] => UPPER(%BrowseFreeElement)
  1603.               #ELSE
  1604.           IF Sort:Name:Array[%InstancePrefix:CurrentScroll] => %BrowseFreeElement
  1605.               #ENDIF
  1606.             #ELSIF(%BrowseScrollKeyDistribution = 'Runtime')
  1607.               #CASE(%FieldType)
  1608.               #OF('STRING')
  1609.               #OROF('CSTRING')
  1610.               #OROF('PSTRING')
  1611.               #OROF('GROUP')
  1612.                 #IF(%KeyNoCase)
  1613.           IF %BrowsePrefix:KeyDistribution[%InstancePrefix:CurrentScroll] => UPPER(%BrowseFreeElement)
  1614.                 #ELSE
  1615.           IF %BrowsePrefix:KeyDistribution[%InstancePrefix:CurrentScroll] => %BrowseFreeElement
  1616.                 #ENDIF
  1617.               #ELSE
  1618.           IF %BrowsePrefix:KeyDistribution[%InstancePrefix:CurrentScroll] => %BrowseFreeElement
  1619.               #ENDCASE
  1620.             #ENDIF
  1621.             IF %InstancePrefix:CurrentScroll <= 1
  1622.               %InstancePrefix:CurrentScroll = 0
  1623.             #IF(%BrowseScrollKeyDistribution = 'Custom')
  1624.             ELSIF %InstancePrefix:CurrentScroll = %BrowseKeyDistributionCount
  1625.             #ELSE
  1626.             ELSIF %InstancePrefix:CurrentScroll = 100
  1627.             #ENDIF
  1628.               %InstancePrefix:CurrentScroll = 100
  1629.             ELSE
  1630.             #IF(%BrowseScrollKeyDistribution = 'Custom')
  1631.               %InstancePrefix:CurrentScroll = ((%InstancePrefix:CurrentScroll / %BrowseKeyDistributionCount) * 100)
  1632.             #ENDIF
  1633.             END
  1634.             BREAK
  1635.           END
  1636.           #ENDIF
  1637.         END
  1638.         #ENDIF
  1639.       #ENDFOR
  1640.       #?END
  1641.     #RESUME
  1642.     ELSE
  1643.       IF %ListControl{Prop:VScroll} = True
  1644.         %ListControl{Prop:VScroll} = False
  1645.       END
  1646.     END
  1647.   #ENDIF
  1648.     DO RefreshWindow
  1649.   END
  1650. #!---------------------------------------------------------------------
  1651. #GROUP(%BrowseRoutineProcessScroll)
  1652. !---------------------------------------------------------------------
  1653. %InstancePrefix:ProcessScroll ROUTINE
  1654.   IF %InstancePrefix:RecordCount
  1655.     %InstancePrefix:CurrentEvent = EVENT()
  1656.     CASE %InstancePrefix:CurrentEvent
  1657.     OF Event:ScrollUp OROF Event:ScrollDown
  1658.       DO %InstancePrefix:ScrollOne
  1659.     OF Event:PageUp OROF Event:PageDown
  1660.       DO %InstancePrefix:ScrollPage
  1661.     OF Event:ScrollTop OROF Event:ScrollBottom
  1662.       DO %InstancePrefix:ScrollEnd
  1663.     END
  1664.     %ListControl{Prop:SelStart} = %InstancePrefix:CurrentChoice
  1665.     DO %InstancePrefix:PostNewSelection
  1666.   #SUSPEND
  1667.     #?CASE %InstancePrefix:SortOrder
  1668.     #FOR(%BrowseAccessID),WHERE(%BrowseLocatorType = 'Incremental')
  1669.     OF %BrowseAccessID
  1670.       %BrowsePrefix:LocatorValue = ''
  1671.       %BrowsePrefix:LocatorLength = 0
  1672.       %BrowseLocatorName = %BrowsePrefix:LocatorValue
  1673.     #ENDFOR
  1674.     #?END
  1675.   #RESUME
  1676.   #SUSPEND
  1677.   #?CASE %InstancePrefix:SortOrder
  1678.     #SET(%ValueConstruct,%False)
  1679.     #FOR(%BrowseAccessID),WHERE(%BrowseScrollBehavior='Fixed Thumb')
  1680.       #IF(%ValueConstruct)
  1681.   OROF %BrowseAccessID
  1682.       #ELSE
  1683.   OF %BrowseAccessID
  1684.         #SET(%ValueConstruct,%True)
  1685.       #ENDIF
  1686.     #ENDFOR
  1687.     #IF(%VerticalScrollBarFound)
  1688.     #?%InstancePrefix:CurrentScroll = 50         #<! Move Thumb to center
  1689.     #?IF %InstancePrefix:RecordCount = %ListControl{Prop:Items}
  1690.       #?IF %InstancePrefix:ItemsToFill
  1691.         #?IF %InstancePrefix:CurrentEvent = Event:ScrollUp
  1692.           #?%InstancePrefix:CurrentScroll = 0
  1693.         #?ELSE
  1694.           #?%InstancePrefix:CurrentScroll = 100
  1695.         #?END
  1696.       #?END
  1697.     #?ELSE
  1698.       #?%InstancePrefix:CurrentScroll = 0
  1699.     #?END
  1700.     #ENDIF
  1701.   #?END
  1702.   #RESUME
  1703.   END
  1704. #!---------------------------------------------------------------------
  1705. #GROUP(%BrowseRoutineScrollOne)
  1706. !----------------------------------------------------------------------
  1707. %InstancePrefix:ScrollOne ROUTINE
  1708.   #SUSPEND
  1709.   #?IF %InstancePrefix:CurrentEvent = Event:ScrollUp
  1710.     #EMBED(%StartScrollUp,'INTERNAL: Start of Scroll Up ROUTINE'),HIDE
  1711.   #?ELSE
  1712.     #EMBED(%StartScrollDown,'INTERNAL: Start of Scroll Down ROUTINE'),HIDE
  1713.   #?END
  1714.   #RESUME
  1715.   IF %InstancePrefix:CurrentEvent = Event:ScrollUp AND %InstancePrefix:CurrentChoice > 1
  1716.     %InstancePrefix:CurrentChoice -= 1
  1717.     EXIT
  1718.   ELSIF %InstancePrefix:CurrentEvent = Event:ScrollDown AND %InstancePrefix:CurrentChoice < %InstancePrefix:RecordCount
  1719.     %InstancePrefix:CurrentChoice += 1
  1720.     EXIT
  1721.   END
  1722.   %InstancePrefix:ItemsToFill = 1
  1723.   %InstancePrefix:FillDirection = %InstancePrefix:CurrentEvent - 2
  1724.   DO %InstancePrefix:FillRecord
  1725.   #SUSPEND
  1726.   #?IF %InstancePrefix:CurrentEvent = Event:ScrollUp
  1727.     #EMBED(%EndScrollUp,'INTERNAL: End of Scroll Up ROUTINE'),HIDE
  1728.   #?ELSE
  1729.     #EMBED(%EndScrollDown,'INTERNAL: End of Scroll Down ROUTINE'),HIDE
  1730.   #?END
  1731.   #RESUME
  1732. #!---------------------------------------------------------------------
  1733. #GROUP(%BrowseRoutineScrollPage)
  1734. !----------------------------------------------------------------------
  1735. %InstancePrefix:ScrollPage ROUTINE
  1736.   #SUSPEND
  1737.   #?IF %InstancePrefix:CurrentEvent = Event:PageUp
  1738.     #EMBED(%StartPageUp,'INTERNAL: Start of Page Up ROUTINE'),HIDE
  1739.   #?ELSE
  1740.     #EMBED(%StartPageDown,'INTERNAL: Start of Page Down ROUTINE'),HIDE
  1741.   #?END
  1742.   #RESUME
  1743.   %InstancePrefix:ItemsToFill = %ListControl{Prop:Items}
  1744.   %InstancePrefix:FillDirection = %InstancePrefix:CurrentEvent - 4
  1745.   DO %InstancePrefix:FillRecord                           ! Fill with next read(s)
  1746.   IF %InstancePrefix:ItemsToFill
  1747.     IF %InstancePrefix:CurrentEvent = Event:PageUp
  1748.       %InstancePrefix:CurrentChoice -= %InstancePrefix:ItemsToFill
  1749.       IF %InstancePrefix:CurrentChoice < 1
  1750.         %InstancePrefix:CurrentChoice = 1
  1751.       END
  1752.     ELSE
  1753.       %InstancePrefix:CurrentChoice += %InstancePrefix:ItemsToFill
  1754.       IF %InstancePrefix:CurrentChoice > %InstancePrefix:RecordCount
  1755.         %InstancePrefix:CurrentChoice = %InstancePrefix:RecordCount
  1756.       END
  1757.     END
  1758.   END
  1759.   #SUSPEND
  1760.   #?IF %InstancePrefix:CurrentEvent = Event:PageUp
  1761.     #EMBED(%EndPageUp,'INTERNAL: End of Page Up ROUTINE'),HIDE
  1762.   #?ELSE
  1763.     #EMBED(%EndPageDown,'INTERNAL: End of Page Down ROUTINE'),HIDE
  1764.   #?END
  1765.   #RESUME
  1766. #!---------------------------------------------------------------------
  1767. #GROUP(%BrowseRoutineScrollEnd)
  1768. !----------------------------------------------------------------------
  1769. %InstancePrefix:ScrollEnd ROUTINE
  1770.   #SUSPEND
  1771.   #?IF %InstancePrefix:CurrentEvent = Event:ScrollTop
  1772.     #EMBED(%StartScrollTop,'INTERNAL: Start of Scroll Top ROUTINE'),HIDE
  1773.   #?ELSE
  1774.     #EMBED(%StartScrollBottom,'INTERNAL: Start of Scroll Bottom ROUTINE'),HIDE
  1775.   #?END
  1776.   #RESUME
  1777.   FREE(%ListQueue)
  1778.   %InstancePrefix:RecordCount = 0
  1779.   DO %InstancePrefix:Reset
  1780.   %InstancePrefix:ItemsToFill = %ListControl{Prop:Items}
  1781.   IF %InstancePrefix:CurrentEvent = Event:ScrollTop
  1782.     %InstancePrefix:FillDirection = FillForward
  1783.   ELSE
  1784.     %InstancePrefix:FillDirection = FillBackward
  1785.   END
  1786.   DO %InstancePrefix:FillRecord                           ! Fill with next read(s)
  1787.   IF %InstancePrefix:CurrentEvent = Event:ScrollTop
  1788.     %InstancePrefix:CurrentChoice = 1
  1789.   ELSE
  1790.     %InstancePrefix:CurrentChoice = %InstancePrefix:RecordCount
  1791.   END
  1792.   #SUSPEND
  1793.   #?IF %InstancePrefix:CurrentEvent = Event:ScrollTop
  1794.     #EMBED(%EndScrollTop,'INTERNAL: End of Scroll Top ROUTINE'),HIDE
  1795.   #?ELSE
  1796.     #EMBED(%EndScrollBottom,'INTERNAL: End of Scroll Bottom ROUTINE'),HIDE
  1797.   #?END
  1798.   #RESUME
  1799. #!----------------------------------------------------------------------
  1800. #GROUP(%BrowseRoutineAlertKey)
  1801. !----------------------------------------------------------------------
  1802. %InstancePrefix:AlertKey ROUTINE
  1803.   #EMBED(%StartAlertKey,'INTERNAL: Start of Alert Key ROUTINE'),HIDE
  1804.   #FIX(%Control,%ListControl)
  1805.   #SUSPEND
  1806.   #?IF %InstancePrefix:RecordCount
  1807.     #?CASE KEYCODE()                                #<! What keycode was hit
  1808.     #EMBED(%AlertKeyCaseKEYCODE,'AlertKey routine, inside CASE KEYCODE'),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  1809.     #?OF MouseLeft2
  1810.       #EMBED(%BrowseBoxDoubleClickHandler,'Browse Double Click Handler'),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  1811.       #EMBED(%BrowseBoxDoubleClick,'INTERNAL Browse Box Double Click Handler'),HIDE
  1812.     #EMBED(%BrowseBoxKeyHandlingNoRecords,'Browse Key Handling'),HIDE
  1813.     #EMBED(%BrowseBoxKeyHandling,'Browse Key Handling'),HIDE
  1814.     #SUSPEND
  1815.     #?ELSE                                          #<! ELSE (What keycode was hit)
  1816.       #?CASE %InstancePrefix:SortOrder
  1817.       #FOR(%BrowseAccessID)
  1818.       #?OF %BrowseAccessID
  1819.       #FIX(%File,%Primary)
  1820.       #FIX(%Key,%BrowseKey)
  1821.         #IF(%BrowseLocatorType = 'Incremental')
  1822.         IF KEYCODE() = BSKey
  1823.           IF %BrowsePrefix:LocatorLength
  1824.             %BrowsePrefix:LocatorLength -= 1
  1825.             %BrowsePrefix:LocatorValue = SUB(%BrowsePrefix:LocatorValue,1,%BrowsePrefix:LocatorLength)
  1826.             %BrowseLocatorName = %BrowsePrefix:LocatorValue
  1827.             #SET(%ValueConstruct,%False)
  1828.             #FOR(%KeyField)
  1829.               #IF(%ValueConstruct)
  1830.                 #IF(%KeyFieldSequence = 'ASCENDING')
  1831.             CLEAR(%KeyField)
  1832.                 #ELSE
  1833.             CLEAR(%KeyField,1)
  1834.                 #ENDIF
  1835.               #ELSE
  1836.                 #IF(%KeyField = %BrowseLocatorName)
  1837.                   #SET(%ValueConstruct,%True)
  1838.                 #ENDIF
  1839.               #ENDIF
  1840.             #ENDFOR
  1841.             %InstancePrefix:LocateMode = LocateOnValue
  1842.             DO %InstancePrefix:LocateRecord
  1843.           END
  1844.         ELSIF KEYCODE() = SpaceKey
  1845.           %BrowsePrefix:LocatorValue = SUB(%BrowsePrefix:LocatorValue,1,%BrowsePrefix:LocatorLength) & ' '
  1846.           %BrowsePrefix:LocatorLength += 1
  1847.           %BrowseLocatorName = %BrowsePrefix:LocatorValue
  1848.             #SET(%ValueConstruct,%False)
  1849.             #FOR(%KeyField)
  1850.               #IF(%ValueConstruct)
  1851.                 #IF(%KeyFieldSequence = 'ASCENDING')
  1852.           CLEAR(%KeyField)
  1853.                 #ELSE
  1854.           CLEAR(%KeyField,1)
  1855.                 #ENDIF
  1856.               #ELSE
  1857.                 #IF(%KeyField = %BrowseLocatorName)
  1858.                   #SET(%ValueConstruct,%True)
  1859.                 #ENDIF
  1860.               #ENDIF
  1861.             #ENDFOR
  1862.           %InstancePrefix:LocateMode = LocateOnValue
  1863.           DO %InstancePrefix:LocateRecord
  1864.         ELSIF CHR(KEYCHAR())
  1865.           %BrowsePrefix:LocatorValue = SUB(%BrowsePrefix:LocatorValue,1,%BrowsePrefix:LocatorLength) & CHR(KEYCHAR())
  1866.           %BrowsePrefix:LocatorLength += 1
  1867.           %BrowseLocatorName = %BrowsePrefix:LocatorValue
  1868.             #SET(%ValueConstruct,%False)
  1869.             #FOR(%KeyField)
  1870.               #IF(%ValueConstruct)
  1871.                 #IF(%KeyFieldSequence = 'ASCENDING')
  1872.           CLEAR(%KeyField)
  1873.                 #ELSE
  1874.           CLEAR(%KeyField,1)
  1875.                 #ENDIF
  1876.               #ELSE
  1877.                 #IF(%KeyField = %BrowseLocatorName)
  1878.                   #SET(%ValueConstruct,%True)
  1879.                 #ENDIF
  1880.               #ENDIF
  1881.             #ENDFOR
  1882.           %InstancePrefix:LocateMode = LocateOnValue
  1883.           DO %InstancePrefix:LocateRecord
  1884.         END
  1885.         #ELSIF(%BrowseLocatorType = 'Step')
  1886.         IF CHR(KEYCHAR())
  1887.           %BrowseLocatorName = CHR(KEYCHAR())
  1888.             #SET(%ValueConstruct,%False)
  1889.             #FOR(%KeyField)
  1890.               #IF(%ValueConstruct)
  1891.                 #IF(%KeyFieldSequence = 'ASCENDING')
  1892.           CLEAR(%KeyField)
  1893.                 #ELSE
  1894.           CLEAR(%KeyField,1)
  1895.                 #ENDIF
  1896.               #ELSE
  1897.                 #IF(%KeyField = %BrowseLocatorName)
  1898.                   #SET(%ValueConstruct,%True)
  1899.                 #ENDIF
  1900.               #ENDIF
  1901.             #ENDFOR
  1902.           %InstancePrefix:LocateMode = LocateOnValue
  1903.           DO %InstancePrefix:LocateRecord
  1904.         END
  1905.         #ELSIF(%BrowseLocatorType = 'Entry')
  1906.         IF CHR(KEYCHAR())
  1907.           SELECT(%BrowseLocatorControl)
  1908.           PRESS(CHR(KEYCHAR()))
  1909.         END
  1910.         #ENDIF
  1911.       #ENDFOR
  1912.       #?END
  1913.     #RESUME
  1914.     #?END                                           #<! END (What keycode was hit)
  1915.   #?ELSE
  1916.     #?CASE KEYCODE()                                #<! What keycode was hit
  1917.     #EMBED(%BrowseBoxKeyHandlingNoRecords,'Browse Key Handling'),HIDE
  1918.     #?END
  1919.   #?END
  1920.   DO %InstancePrefix:PostNewSelection
  1921.   #RESUME
  1922.   #EMBED(%EndAlertKey,'INTERNAL: End of Alert Key ROUTINE'),HIDE
  1923. #!----------------------------------------------------------------------
  1924. #GROUP(%BrowseRoutineScrollDrag)
  1925. !----------------------------------------------------------------------
  1926. #IF(%VerticalScrollBarFound)
  1927. %InstancePrefix:ScrollDrag ROUTINE
  1928.   IF %ListControl{Prop:VScrollPos} <= 1
  1929.     POST(Event:ScrollTop,%ListControl)
  1930.   ELSIF %ListControl{Prop:VScrollPos} = 100
  1931.     POST(Event:ScrollBottom,%ListControl)
  1932.   ELSE
  1933.   #SUSPEND
  1934.     #?CASE %InstancePrefix:SortOrder
  1935.     #FOR(%BrowseAccessID),WHERE(%BrowseScrollBehavior = 'Movable Thumb')
  1936.     #?OF %BrowseAccessID
  1937.       #IF(%BrowseScrollKeyDistribution = 'Alpha')
  1938.       %BrowseFreeElement = Sort:Alpha:Array[%ListControl{Prop:VScrollPos}]
  1939.       #ELSIF(%BrowseScrollKeyDistribution = 'Last Names')
  1940.       %BrowseFreeElement = Sort:Name:Array[%ListControl{Prop:VScrollPos}]
  1941.       #ELSIF(%BrowseScrollKeyDistribution = 'Runtime')
  1942.       %BrowseFreeElement = %BrowsePrefix:KeyDistribution[%ListControl{Prop:VScrollPos}]
  1943.       #ELSIF(%BrowseScrollKeyDistribution = 'Custom')
  1944.       %BrowseFreeElement = %BrowsePrefix:KeyDistribution[(%BrowseKeyDistributionCount * %ListControl{Prop:VScrollPos})/100]
  1945.       #ENDIF
  1946.       #?%InstancePrefix:LocateMode = LocateOnValue
  1947.       #?DO %InstancePrefix:LocateRecord
  1948.     #ENDFOR
  1949.     #?END
  1950.   #RESUME
  1951.   END
  1952. #ENDIF
  1953. #!----------------------------------------------------------------------
  1954. #GROUP(%BrowseRoutineValidateRecord)
  1955. #SET(%BeginningOffset,%BytesOutput)
  1956. #SUSPEND
  1957. #?!----------------------------------------------------------------------
  1958. #?%InstancePrefix:ValidateRecord ROUTINE
  1959.   #EMBED(%StartValidateRecordRoutine,'Start of Validate Record ROUTINE'),HIDE
  1960.   #SUSPEND
  1961.   #?%InstancePrefix:RecordStatus = Record:OutOfRange
  1962.   #INSERT(%StandardFormula,'Before Range Limits')
  1963.   #EMBED(%RecordOutOfRange,'Validate Record: Range Checking'),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActivetemplateInstanceDescription)
  1964.   #INSERT(%StandardFormula,'Before Filter')
  1965.   #?%InstancePrefix:RecordStatus = Record:Filtered
  1966.   #EMBED(%RecordFilter,'Validate Record: Filter Checking'),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActivetemplateInstanceDescription)
  1967.   #EMBED(%AfterRangeFilterCheck,'After Range and Filter Check'),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActivetemplateInstanceDescription)
  1968.   #RESUME
  1969.   #?%InstancePrefix:RecordStatus = Record:OK
  1970.   #EMBED(%EndValidateRecordRoutine,'End of Validate Record ROUTINE'),HIDE
  1971.   #?EXIT
  1972. #RESUME
  1973. #SET(%EndingOffset,%BytesOutput)
  1974. #IF(%BeginningOffset=%EndingOffset)
  1975.   #SET(%UseValidateRoutine,%False)
  1976. #ELSE
  1977.   #SET(%UseValidateRoutine,%True)
  1978. #ENDIF
  1979. #!----------------------------------------------------------------------
  1980. #GROUP(%BrowseRoutineFillRecord)
  1981. !----------------------------------------------------------------------
  1982. %InstancePrefix:FillRecord ROUTINE
  1983.   #SUSPEND
  1984.   #?IF %InstancePrefix:FillDirection = FillForward
  1985.     #EMBED(%StartFillForwardRoutine,'Start of Fill Forward ROUTINE')
  1986.     #EMBED(%StartFillRecordRoutineForward,'Start of Fill Record ROUTINE, Reading Forward')
  1987.   #?ELSE
  1988.     #EMBED(%StartBackwardRoutine,'Start of Fill Backward ROUTINE')
  1989.     #EMBED(%StartFillRecordRoutineBackward,'Start of Fill Record ROUTINE, Reading Backward')
  1990.   #?END
  1991.   #RESUME
  1992.   #IF(%EnableQuickScan)
  1993.   IF %InstancePrefix:ItemsToFill > 1
  1994.     #EMBED(%BeforeTurnQuickScanOn,'Before Turning QuickScan On'),WHERE(%EnableQuickScan)
  1995.     IF SEND(%Primary,'QUICKSCAN=on').
  1996.     %InstancePrefix:QuickScan = True
  1997.     #EMBED(%AfterTurnQuickScanOn,'After Turning QuickScan On'),WHERE(%EnableQuickScan)
  1998.   END
  1999.   #ENDIF
  2000.   IF %InstancePrefix:RecordCount
  2001.     IF %InstancePrefix:FillDirection = FillForward
  2002.       GET(%ListQueue,%InstancePrefix:RecordCount)    #<! Get the first queue item
  2003.     ELSE
  2004.       GET(%ListQueue,1)                              #<! Get the first queue item
  2005.     END
  2006.     RESET(%ListView,%InstancePrefix:Position)        #<! Reset for sequential processing
  2007.     NEXT(%ListView)
  2008.     IF ERRORCODE()
  2009.       IF ERRORCODE() = BadRecErr
  2010.         DO %InstancePrefix:RestoreResetValues
  2011.       ELSE
  2012.         StandardWarning(Warn:RecordFetchError,'%File')
  2013.         POST(Event:CloseWindow)
  2014.         EXIT
  2015.       END
  2016.     END
  2017.   END
  2018.   LOOP WHILE %InstancePrefix:ItemsToFill
  2019.     IF %InstancePrefix:FillDirection = FillForward
  2020.       NEXT(%ListView)
  2021.     ELSE
  2022.       PREVIOUS(%ListView)
  2023.     END
  2024.     IF ERRORCODE()
  2025.       IF ERRORCODE() = BadRecErr
  2026.         DO %InstancePrefix:RestoreResetValues
  2027.         BREAK
  2028.       ELSE
  2029.         StandardWarning(Warn:RecordFetchError,'%File')
  2030.         POST(Event:CloseWindow)
  2031.         EXIT
  2032.       END
  2033.     END
  2034.   #IF(%UseValidateRoutine)
  2035.     DO %InstancePrefix:ValidateRecord
  2036.     EXECUTE(%InstancePrefix:RecordStatus)
  2037.       BEGIN
  2038.         IF %InstancePrefix:FillDirection = FillForward
  2039.           GET(%ListQueue,%InstancePrefix:RecordCount)            #<! Get the first queue item
  2040.         ELSE
  2041.           GET(%ListQueue,1)                              #<! Get the first queue item
  2042.         END
  2043.         DO %InstancePrefix:FillBuffer
  2044.         BREAK
  2045.       END
  2046.       CYCLE
  2047.     END
  2048.   #ENDIF
  2049.     IF %InstancePrefix:AddQueue
  2050.       IF %InstancePrefix:RecordCount = %ListControl{Prop:Items}
  2051.         IF %InstancePrefix:FillDirection = FillForward
  2052.           GET(%ListQueue,1)                              #<! Get the first queue item
  2053.         ELSE
  2054.           GET(%ListQueue,%InstancePrefix:RecordCount)    #<! Get the first queue item
  2055.         END
  2056.         DELETE(%ListQueue)
  2057.         %InstancePrefix:RecordCount -= 1
  2058.       END
  2059.       DO %InstancePrefix:FillQueue
  2060.       IF %InstancePrefix:FillDirection = FillForward
  2061.         ADD(%ListQueue)
  2062.       ELSE
  2063.         ADD(%ListQueue,1)
  2064.       END
  2065.       %InstancePrefix:RecordCount += 1
  2066.     END
  2067.     %InstancePrefix:ItemsToFill -= 1
  2068.   END
  2069.   #IF(%EnableQuickScan)
  2070.   IF %InstancePrefix:QuickScan
  2071.     #EMBED(%BeforeTurnQuickScanOn,'Before Turning QuickScan Off'),WHERE(%EnableQuickScan)
  2072.     IF SEND(%Primary,'QUICKSCAN=off').
  2073.     %InstancePrefix:QuickScan = False
  2074.     #EMBED(%AfterTurnQuickScanOn,'After Turning QuickScan Off'),WHERE(%EnableQuickScan)
  2075.   END
  2076.   #ENDIF
  2077.   %InstancePrefix:AddQueue = True
  2078.   #SUSPEND
  2079.   #?IF %InstancePrefix:FillDirection = FillForward
  2080.     #EMBED(%EndFillForwardRoutine,'End of Fill Forward ROUTINE')
  2081.     #EMBED(%EndFillRecordRoutineForward,'End of Fill Record ROUTINE, Reading Forward')
  2082.   #?ELSE
  2083.     #EMBED(%EndBackwardRoutine,'End of Fill Backward ROUTINE')
  2084.     #EMBED(%EndFillRecordRoutineBackward,'End of Fill Record ROUTINE, Reading Backward')
  2085.   #?END
  2086.   #RESUME
  2087.   EXIT
  2088. #!----------------------------------------------------------------------
  2089. #GROUP(%BrowseRoutineLocateRecord)
  2090. !----------------------------------------------------------------------
  2091. %InstancePrefix:LocateRecord ROUTINE
  2092.   #EMBED(%StartLocateRecordRoutine,'Start of Locate Record ROUTINE'),HIDE
  2093.   IF %InstancePrefix:LocateMode = LocateOnPosition
  2094.     %InstancePrefix:HighlightedPosition = POSITION(%ListView)
  2095.     RESET(%ListView,%InstancePrefix:HighlightedPosition)
  2096.   ELSE
  2097.     CLOSE(%ListView)
  2098.     CASE %InstancePrefix:SortOrder
  2099.   #FOR(%BrowseAccessID)
  2100.     OF %BrowseAccessID
  2101.     #IF(%BrowseKey)
  2102.       #FOR(%BrowseRangeLimitField)
  2103.         #IF(%BrowseRangeLimitType = 'Range of Values' AND INSTANCE(%BrowseRangeLimitField) = ITEMS(%BrowseRangeLimitField))
  2104.           #BREAK
  2105.         #ENDIF
  2106.       %BrowseRangeLimitField = %BrowseRangeLimitValue
  2107.       #ENDFOR
  2108.       IF %InstancePrefix:LocateMode = LocateOnValue
  2109.          SET(%BrowseKey,%BrowseKey)
  2110.       ELSE
  2111.         SET(%BrowseKey)
  2112.       END
  2113.     #ELSE
  2114.       IF %InstancePrefix:LocateMode = LocateOnValue
  2115.         IF POSITION(%Primary)
  2116.           RESET(%Primary,POSITION(%Primary))
  2117.         ELSE
  2118.           SET(%Primary)
  2119.         END
  2120.       ELSE
  2121.         SET(%Primary)
  2122.       END
  2123.     #ENDIF
  2124.     #IF(%BrowseFiltersExist)
  2125.       %ListView{Prop:Filter} = '%'BrowseFilterStatement'
  2126.     #ELSE
  2127.       %ListView{Prop:Filter} = ''
  2128.     #ENDIF
  2129.   #ENDFOR
  2130.     END
  2131.     OPEN(%ListView)
  2132.   END
  2133.   FREE(%ListQueue)
  2134.   %InstancePrefix:RecordCount = 0
  2135.   %InstancePrefix:ItemsToFill = 1
  2136.   %InstancePrefix:FillDirection = FillForward   #<! Fill with next read(s)
  2137.   %InstancePrefix:AddQueue = False
  2138.   DO %InstancePrefix:FillRecord                 #<! Fill with next read(s)
  2139.   %InstancePrefix:AddQueue = True
  2140.   IF %InstancePrefix:ItemsToFill
  2141.     %InstancePrefix:RefreshMode = RefreshOnBottom
  2142.     DO %InstancePrefix:RefreshPage
  2143.   ELSE
  2144.     %InstancePrefix:RefreshMode = RefreshOnPosition
  2145.     DO %InstancePrefix:RefreshPage
  2146.   END
  2147.   DO %InstancePrefix:PostNewSelection
  2148.   %InstancePrefix:LocateMode = 0
  2149.   EXIT
  2150. #!----------------------------------------------------------------------
  2151. #GROUP(%BrowseRoutineRefreshPage)
  2152. !----------------------------------------------------------------------
  2153. %InstancePrefix:RefreshPage ROUTINE
  2154.   #EMBED(%StartRefreshPageRoutine,'Start of Refresh Page ROUTINE'),HIDE
  2155.   SETCURSOR(Cursor:Wait)
  2156.   IF %InstancePrefix:RefreshMode = RefreshOnPosition
  2157.     %InstancePrefix:HighlightedPosition = POSITION(%ListView)
  2158.     RESET(%ListView,%InstancePrefix:HighlightedPosition)
  2159.     %InstancePrefix:RefreshMode = RefreshOnTop
  2160.   ELSIF RECORDS(%ListQueue)
  2161.     GET(%ListQueue,%InstancePrefix:CurrentChoice)
  2162.     IF ERRORCODE()
  2163.       GET(%ListQueue,RECORDS(%ListQueue))
  2164.     END
  2165.     %InstancePrefix:HighlightedPosition = %InstancePrefix:Position
  2166.     GET(%ListQueue,1)
  2167.     RESET(%ListView,%InstancePrefix:Position)
  2168.     %InstancePrefix:RefreshMode = RefreshOnCurrent
  2169.   ELSE
  2170.     %InstancePrefix:HighlightedPosition = ''
  2171.     DO %InstancePrefix:Reset
  2172.   END
  2173.   FREE(%ListQueue)
  2174.   %InstancePrefix:RecordCount = 0
  2175.   %InstancePrefix:ItemsToFill = %ListControl{Prop:Items}
  2176.   IF %InstancePrefix:RefreshMode = RefreshOnBottom
  2177.     %InstancePrefix:FillDirection = FillBackward
  2178.   ELSE
  2179.     %InstancePrefix:FillDirection = FillForward
  2180.   END
  2181.   DO %InstancePrefix:FillRecord                 #<! Fill with next read(s)
  2182.   IF %InstancePrefix:HighlightedPosition
  2183.     IF %InstancePrefix:ItemsToFill
  2184.       IF NOT %InstancePrefix:RecordCount
  2185.         DO %InstancePrefix:Reset
  2186.       END
  2187.       IF %InstancePrefix:RefreshMode = RefreshOnBottom
  2188.         %InstancePrefix:FillDirection = FillForward
  2189.       ELSE
  2190.         %InstancePrefix:FillDirection = FillBackward
  2191.       END
  2192.       DO %InstancePrefix:FillRecord
  2193.     END
  2194.   END
  2195.   IF %InstancePrefix:RecordCount
  2196.     #SUSPEND
  2197.     #?CASE %InstancePrefix:SortOrder
  2198.       #SET(%ValueConstruct,%False)
  2199.       #FOR(%BrowseAccessID),WHERE(%BrowseLocatorControl)
  2200.     OF %BrowseAccessID; %BrowseLocatorControl{Prop:Disable} = 0
  2201.       #ENDFOR
  2202.     #?END
  2203.     #RESUME
  2204.     IF %InstancePrefix:HighlightedPosition
  2205.       LOOP %InstancePrefix:CurrentChoice = 1 TO %InstancePrefix:RecordCount
  2206.         GET(%ListQueue,%InstancePrefix:CurrentChoice)
  2207.         IF %InstancePrefix:Position = %InstancePrefix:HighlightedPosition THEN BREAK.
  2208.       END
  2209.       IF %InstancePrefix:CurrentChoice > %InstancePrefix:RecordCount
  2210.         %InstancePrefix:CurrentChoice = %InstancePrefix:RecordCount
  2211.       END
  2212.     ELSE
  2213.       IF %InstancePrefix:RefreshMode = RefreshOnBottom
  2214.         %InstancePrefix:CurrentChoice = RECORDS(%ListQueue)
  2215.       ELSE
  2216.         %InstancePrefix:CurrentChoice = 1
  2217.       END
  2218.     END
  2219.     %ListControl{Prop:Selected} = %InstancePrefix:CurrentChoice
  2220.     DO %InstancePrefix:FillBuffer
  2221.     #EMBED(%BrowseBoxNotEmpty,'Browse Box, Records Found'),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  2222.   ELSE
  2223.     #FIX(%File,%Primary)
  2224.     CLEAR(%FilePrefix:Record)
  2225.     #FOR(%Field),WHERE(%FieldType='MEMO')
  2226.     CLEAR(%Field)
  2227.     #ENDFOR
  2228.     #SUSPEND
  2229.     #?CASE %InstancePrefix:SortOrder
  2230.       #SET(%ValueConstruct,%False)
  2231.       #FOR(%BrowseAccessID),WHERE(%BrowseLocatorControl)
  2232.     OF %BrowseAccessID; %BrowseLocatorControl{Prop:Disable} = 1
  2233.       #ENDFOR
  2234.     #?END
  2235.     #RESUME
  2236.     #FIX(%Control,%ListControl)
  2237.     %InstancePrefix:CurrentChoice = 0
  2238.     #EMBED(%BrowseBoxEmpty,'Browse Box, No Records Found'),%ActiveTemplateInstance,MAP(%ActiveTemplateInstance,%ActiveTemplateinstanceDescription)
  2239.   END
  2240.   SETCURSOR()
  2241.   #EMBED(%EndRefreshPageRoutine,'End of Refresh Page ROUTINE'),HIDE
  2242.   %InstancePrefix:RefreshMode = 0
  2243.   EXIT
  2244. #!----------------------------------------------------------------------
  2245. #GROUP(%BrowseRoutineGetRecord)
  2246. !----------------------------------------------------------------------
  2247. %InstancePrefix:GetRecord ROUTINE
  2248.   IF %InstancePrefix:RecordCount
  2249.     %InstancePrefix:CurrentChoice = CHOICE(%ListControl)
  2250.     GET(%ListQueue,%InstancePrefix:CurrentChoice)
  2251.     WATCH(%ListView)
  2252.     REGET(%ListView,%InstancePrefix:Position)
  2253.   END
  2254. #!----------------------------------------------------------------------
  2255. #GROUP(%BrowseRoutineRestoreResetValues)
  2256. !----------------------------------------------------------------------
  2257. %InstancePrefix:RestoreResetValues ROUTINE
  2258.   #SUSPEND
  2259.   #?CASE %InstancePrefix:SortOrder
  2260.     #FOR(%BrowseAccessID)
  2261.       #SUSPEND
  2262.   #?OF %BrowseAccessID
  2263.         #FOR(%BrowseResetField)
  2264.     %BrowseResetField = %BrowsePrefix:Reset:%BrowseResetField
  2265.         #ENDFOR
  2266.       #RESUME
  2267.     #ENDFOR
  2268.   #?END
  2269.   #RESUME
  2270. #INCLUDE('CtlBrowA.TPW')                         #! Additional controls
  2271.                                                  #! linked to BrowseBox